< Summary

Class:Azure.ResourceManager.Compute.VirtualMachinesRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachinesRestOperations.cs
Covered lines:516
Uncovered lines:447
Coverable lines:963
Total lines:2062
Line coverage:53.5% (516 of 963)
Covered branches:137
Total branches:394
Branch coverage:34.7% (137 of 394)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateListByLocationRequest(...)-100%100%
ListByLocationAsync()-76.92%50%
ListByLocation(...)-76.92%50%
CreateCaptureRequest(...)-0%100%
CaptureAsync()-0%0%
Capture(...)-0%0%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-75%62.5%
CreateOrUpdate(...)-75%62.5%
CreateUpdateRequest(...)-100%100%
UpdateAsync()-66.67%50%
Update(...)-66.67%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateGetRequest(...)-100%100%
GetAsync()-73.33%50%
Get(...)-73.33%50%
CreateInstanceViewRequest(...)-100%100%
InstanceViewAsync()-73.33%50%
InstanceView(...)-73.33%50%
CreateConvertToManagedDisksRequest(...)-0%100%
ConvertToManagedDisksAsync()-0%0%
ConvertToManagedDisks(...)-0%0%
CreateDeallocateRequest(...)-100%100%
DeallocateAsync()-70%62.5%
Deallocate(...)-70%62.5%
CreateGeneralizeRequest(...)-0%100%
GeneralizeAsync()-0%0%
Generalize(...)-0%0%
CreateListRequest(...)-100%100%
ListAsync()-76.92%50%
List(...)-76.92%50%
CreateListAllRequest(...)-92.31%50%
ListAllAsync()-81.82%50%
ListAll(...)-81.82%50%
CreateListAvailableSizesRequest(...)-100%100%
ListAvailableSizesAsync()-73.33%50%
ListAvailableSizes(...)-73.33%50%
CreatePowerOffRequest(...)-100%100%
PowerOffAsync()-70%62.5%
PowerOff(...)-70%62.5%
CreateReapplyRequest(...)-100%100%
ReapplyAsync()-70%62.5%
Reapply(...)-70%62.5%
CreateRestartRequest(...)-0%100%
RestartAsync()-0%0%
Restart(...)-0%0%
CreateStartRequest(...)-100%100%
StartAsync()-70%62.5%
Start(...)-70%62.5%
CreateRedeployRequest(...)-100%100%
RedeployAsync()-70%62.5%
Redeploy(...)-70%62.5%
CreateReimageRequest(...)-0%0%
ReimageAsync()-0%0%
Reimage(...)-0%0%
CreatePerformMaintenanceRequest(...)-100%100%
PerformMaintenanceAsync()-60%50%
PerformMaintenance(...)-60%50%
CreateSimulateEvictionRequest(...)-100%100%
SimulateEvictionAsync()-70%50%
SimulateEviction(...)-70%50%
CreateRunCommandRequest(...)-0%100%
RunCommandAsync()-0%0%
RunCommand(...)-0%0%
CreateListByLocationNextPageRequest(...)-0%100%
ListByLocationNextPageAsync()-0%0%
ListByLocationNextPage(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%
CreateListAllNextPageRequest(...)-0%100%
ListAllNextPageAsync()-0%0%
ListAllNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachinesRestOperations.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 VirtualMachinesRestOperations
 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 VirtualMachinesRestOperations. </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 VirtualMachinesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip
 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 CreateListByLocationRequest(string location)
 47        {
 448            var message = _pipeline.CreateMessage();
 449            var request = message.Request;
 450            request.Method = RequestMethod.Get;
 451            var uri = new RawRequestUriBuilder();
 452            uri.Reset(endpoint);
 453            uri.AppendPath("/subscriptions/", false);
 454            uri.AppendPath(subscriptionId, true);
 455            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 456            uri.AppendPath(location, true);
 457            uri.AppendPath("/virtualMachines", false);
 458            uri.AppendQuery("api-version", "2019-12-01", true);
 459            request.Uri = uri;
 460            return message;
 61        }
 62
 63        /// <summary> Gets all the virtual machines under the specified subscription for the specified location. </summa
 64        /// <param name="location"> The location for which virtual machines under the subscription are queried. </param>
 65        /// <param name="cancellationToken"> The cancellation token to use. </param>
 66        public async Task<Response<VirtualMachineListResult>> ListByLocationAsync(string location, CancellationToken can
 67        {
 268            if (location == null)
 69            {
 070                throw new ArgumentNullException(nameof(location));
 71            }
 72
 273            using var message = CreateListByLocationRequest(location);
 274            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 275            switch (message.Response.Status)
 76            {
 77                case 200:
 78                    {
 279                        VirtualMachineListResult value = default;
 280                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 281                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 82                        {
 083                            value = null;
 84                        }
 85                        else
 86                        {
 287                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 88                        }
 289                        return Response.FromValue(value, message.Response);
 90                    }
 91                default:
 092                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 93            }
 294        }
 95
 96        /// <summary> Gets all the virtual machines under the specified subscription for the specified location. </summa
 97        /// <param name="location"> The location for which virtual machines under the subscription are queried. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public Response<VirtualMachineListResult> ListByLocation(string location, CancellationToken cancellationToken = 
 100        {
 2101            if (location == null)
 102            {
 0103                throw new ArgumentNullException(nameof(location));
 104            }
 105
 2106            using var message = CreateListByLocationRequest(location);
 2107            _pipeline.Send(message, cancellationToken);
 2108            switch (message.Response.Status)
 109            {
 110                case 200:
 111                    {
 2112                        VirtualMachineListResult value = default;
 2113                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2114                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 115                        {
 0116                            value = null;
 117                        }
 118                        else
 119                        {
 2120                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 121                        }
 2122                        return Response.FromValue(value, message.Response);
 123                    }
 124                default:
 0125                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 126            }
 2127        }
 128
 129        internal HttpMessage CreateCaptureRequest(string resourceGroupName, string vmName, VirtualMachineCaptureParamete
 130        {
 0131            var message = _pipeline.CreateMessage();
 0132            var request = message.Request;
 0133            request.Method = RequestMethod.Post;
 0134            var uri = new RawRequestUriBuilder();
 0135            uri.Reset(endpoint);
 0136            uri.AppendPath("/subscriptions/", false);
 0137            uri.AppendPath(subscriptionId, true);
 0138            uri.AppendPath("/resourceGroups/", false);
 0139            uri.AppendPath(resourceGroupName, true);
 0140            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 0141            uri.AppendPath(vmName, true);
 0142            uri.AppendPath("/capture", false);
 0143            uri.AppendQuery("api-version", "2019-12-01", true);
 0144            request.Uri = uri;
 0145            request.Headers.Add("Content-Type", "application/json");
 0146            var content = new Utf8JsonRequestContent();
 0147            content.JsonWriter.WriteObjectValue(parameters);
 0148            request.Content = content;
 0149            return message;
 150        }
 151
 152        /// <summary> Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to
 153        /// <param name="resourceGroupName"> The name of the resource group. </param>
 154        /// <param name="vmName"> The name of the virtual machine. </param>
 155        /// <param name="parameters"> Parameters supplied to the Capture Virtual Machine operation. </param>
 156        /// <param name="cancellationToken"> The cancellation token to use. </param>
 157        public async Task<Response> CaptureAsync(string resourceGroupName, string vmName, VirtualMachineCaptureParameter
 158        {
 0159            if (resourceGroupName == null)
 160            {
 0161                throw new ArgumentNullException(nameof(resourceGroupName));
 162            }
 0163            if (vmName == null)
 164            {
 0165                throw new ArgumentNullException(nameof(vmName));
 166            }
 0167            if (parameters == null)
 168            {
 0169                throw new ArgumentNullException(nameof(parameters));
 170            }
 171
 0172            using var message = CreateCaptureRequest(resourceGroupName, vmName, parameters);
 0173            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0174            switch (message.Response.Status)
 175            {
 176                case 200:
 177                case 202:
 0178                    return message.Response;
 179                default:
 0180                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 181            }
 0182        }
 183
 184        /// <summary> Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to
 185        /// <param name="resourceGroupName"> The name of the resource group. </param>
 186        /// <param name="vmName"> The name of the virtual machine. </param>
 187        /// <param name="parameters"> Parameters supplied to the Capture Virtual Machine operation. </param>
 188        /// <param name="cancellationToken"> The cancellation token to use. </param>
 189        public Response Capture(string resourceGroupName, string vmName, VirtualMachineCaptureParameters parameters, Can
 190        {
 0191            if (resourceGroupName == null)
 192            {
 0193                throw new ArgumentNullException(nameof(resourceGroupName));
 194            }
 0195            if (vmName == null)
 196            {
 0197                throw new ArgumentNullException(nameof(vmName));
 198            }
 0199            if (parameters == null)
 200            {
 0201                throw new ArgumentNullException(nameof(parameters));
 202            }
 203
 0204            using var message = CreateCaptureRequest(resourceGroupName, vmName, parameters);
 0205            _pipeline.Send(message, cancellationToken);
 0206            switch (message.Response.Status)
 207            {
 208                case 200:
 209                case 202:
 0210                    return message.Response;
 211                default:
 0212                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 213            }
 0214        }
 215
 216        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string vmName, VirtualMachine paramet
 217        {
 244218            var message = _pipeline.CreateMessage();
 244219            var request = message.Request;
 244220            request.Method = RequestMethod.Put;
 244221            var uri = new RawRequestUriBuilder();
 244222            uri.Reset(endpoint);
 244223            uri.AppendPath("/subscriptions/", false);
 244224            uri.AppendPath(subscriptionId, true);
 244225            uri.AppendPath("/resourceGroups/", false);
 244226            uri.AppendPath(resourceGroupName, true);
 244227            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 244228            uri.AppendPath(vmName, true);
 244229            uri.AppendQuery("api-version", "2019-12-01", true);
 244230            request.Uri = uri;
 244231            request.Headers.Add("Content-Type", "application/json");
 244232            var content = new Utf8JsonRequestContent();
 244233            content.JsonWriter.WriteObjectValue(parameters);
 244234            request.Content = content;
 244235            return message;
 236        }
 237
 238        /// <summary> The operation to create or update a virtual machine. Please note some properties can be set only d
 239        /// <param name="resourceGroupName"> The name of the resource group. </param>
 240        /// <param name="vmName"> The name of the virtual machine. </param>
 241        /// <param name="parameters"> Parameters supplied to the Create Virtual Machine operation. </param>
 242        /// <param name="cancellationToken"> The cancellation token to use. </param>
 243        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string vmName, VirtualMachine paramete
 244        {
 62245            if (resourceGroupName == null)
 246            {
 0247                throw new ArgumentNullException(nameof(resourceGroupName));
 248            }
 62249            if (vmName == null)
 250            {
 0251                throw new ArgumentNullException(nameof(vmName));
 252            }
 62253            if (parameters == null)
 254            {
 0255                throw new ArgumentNullException(nameof(parameters));
 256            }
 257
 62258            using var message = CreateCreateOrUpdateRequest(resourceGroupName, vmName, parameters);
 62259            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 62260            switch (message.Response.Status)
 261            {
 262                case 200:
 263                case 201:
 60264                    return message.Response;
 265                default:
 2266                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 267            }
 60268        }
 269
 270        /// <summary> The operation to create or update a virtual machine. Please note some properties can be set only d
 271        /// <param name="resourceGroupName"> The name of the resource group. </param>
 272        /// <param name="vmName"> The name of the virtual machine. </param>
 273        /// <param name="parameters"> Parameters supplied to the Create Virtual Machine operation. </param>
 274        /// <param name="cancellationToken"> The cancellation token to use. </param>
 275        public Response CreateOrUpdate(string resourceGroupName, string vmName, VirtualMachine parameters, CancellationT
 276        {
 62277            if (resourceGroupName == null)
 278            {
 0279                throw new ArgumentNullException(nameof(resourceGroupName));
 280            }
 62281            if (vmName == null)
 282            {
 0283                throw new ArgumentNullException(nameof(vmName));
 284            }
 62285            if (parameters == null)
 286            {
 0287                throw new ArgumentNullException(nameof(parameters));
 288            }
 289
 62290            using var message = CreateCreateOrUpdateRequest(resourceGroupName, vmName, parameters);
 62291            _pipeline.Send(message, cancellationToken);
 62292            switch (message.Response.Status)
 293            {
 294                case 200:
 295                case 201:
 60296                    return message.Response;
 297                default:
 2298                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 299            }
 60300        }
 301
 302        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string vmName, VirtualMachineUpdate parameter
 303        {
 8304            var message = _pipeline.CreateMessage();
 8305            var request = message.Request;
 8306            request.Method = RequestMethod.Patch;
 8307            var uri = new RawRequestUriBuilder();
 8308            uri.Reset(endpoint);
 8309            uri.AppendPath("/subscriptions/", false);
 8310            uri.AppendPath(subscriptionId, true);
 8311            uri.AppendPath("/resourceGroups/", false);
 8312            uri.AppendPath(resourceGroupName, true);
 8313            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 8314            uri.AppendPath(vmName, true);
 8315            uri.AppendQuery("api-version", "2019-12-01", true);
 8316            request.Uri = uri;
 8317            request.Headers.Add("Content-Type", "application/json");
 8318            var content = new Utf8JsonRequestContent();
 8319            content.JsonWriter.WriteObjectValue(parameters);
 8320            request.Content = content;
 8321            return message;
 322        }
 323
 324        /// <summary> The operation to update a virtual machine. </summary>
 325        /// <param name="resourceGroupName"> The name of the resource group. </param>
 326        /// <param name="vmName"> The name of the virtual machine. </param>
 327        /// <param name="parameters"> Parameters supplied to the Update Virtual Machine operation. </param>
 328        /// <param name="cancellationToken"> The cancellation token to use. </param>
 329        public async Task<Response> UpdateAsync(string resourceGroupName, string vmName, VirtualMachineUpdate parameters
 330        {
 2331            if (resourceGroupName == null)
 332            {
 0333                throw new ArgumentNullException(nameof(resourceGroupName));
 334            }
 2335            if (vmName == null)
 336            {
 0337                throw new ArgumentNullException(nameof(vmName));
 338            }
 2339            if (parameters == null)
 340            {
 0341                throw new ArgumentNullException(nameof(parameters));
 342            }
 343
 2344            using var message = CreateUpdateRequest(resourceGroupName, vmName, parameters);
 2345            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2346            switch (message.Response.Status)
 347            {
 348                case 200:
 349                case 201:
 2350                    return message.Response;
 351                default:
 0352                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 353            }
 2354        }
 355
 356        /// <summary> The operation to update a virtual machine. </summary>
 357        /// <param name="resourceGroupName"> The name of the resource group. </param>
 358        /// <param name="vmName"> The name of the virtual machine. </param>
 359        /// <param name="parameters"> Parameters supplied to the Update Virtual Machine operation. </param>
 360        /// <param name="cancellationToken"> The cancellation token to use. </param>
 361        public Response Update(string resourceGroupName, string vmName, VirtualMachineUpdate parameters, CancellationTok
 362        {
 2363            if (resourceGroupName == null)
 364            {
 0365                throw new ArgumentNullException(nameof(resourceGroupName));
 366            }
 2367            if (vmName == null)
 368            {
 0369                throw new ArgumentNullException(nameof(vmName));
 370            }
 2371            if (parameters == null)
 372            {
 0373                throw new ArgumentNullException(nameof(parameters));
 374            }
 375
 2376            using var message = CreateUpdateRequest(resourceGroupName, vmName, parameters);
 2377            _pipeline.Send(message, cancellationToken);
 2378            switch (message.Response.Status)
 379            {
 380                case 200:
 381                case 201:
 2382                    return message.Response;
 383                default:
 0384                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 385            }
 2386        }
 387
 388        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string vmName)
 389        {
 104390            var message = _pipeline.CreateMessage();
 104391            var request = message.Request;
 104392            request.Method = RequestMethod.Delete;
 104393            var uri = new RawRequestUriBuilder();
 104394            uri.Reset(endpoint);
 104395            uri.AppendPath("/subscriptions/", false);
 104396            uri.AppendPath(subscriptionId, true);
 104397            uri.AppendPath("/resourceGroups/", false);
 104398            uri.AppendPath(resourceGroupName, true);
 104399            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 104400            uri.AppendPath(vmName, true);
 104401            uri.AppendQuery("api-version", "2019-12-01", true);
 104402            request.Uri = uri;
 104403            return message;
 404        }
 405
 406        /// <summary> The operation to delete a virtual machine. </summary>
 407        /// <param name="resourceGroupName"> The name of the resource group. </param>
 408        /// <param name="vmName"> The name of the virtual machine. </param>
 409        /// <param name="cancellationToken"> The cancellation token to use. </param>
 410        public async Task<Response> DeleteAsync(string resourceGroupName, string vmName, CancellationToken cancellationT
 411        {
 26412            if (resourceGroupName == null)
 413            {
 0414                throw new ArgumentNullException(nameof(resourceGroupName));
 415            }
 26416            if (vmName == null)
 417            {
 0418                throw new ArgumentNullException(nameof(vmName));
 419            }
 420
 26421            using var message = CreateDeleteRequest(resourceGroupName, vmName);
 26422            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 26423            switch (message.Response.Status)
 424            {
 425                case 200:
 426                case 202:
 427                case 204:
 26428                    return message.Response;
 429                default:
 0430                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 431            }
 26432        }
 433
 434        /// <summary> The operation to delete a virtual machine. </summary>
 435        /// <param name="resourceGroupName"> The name of the resource group. </param>
 436        /// <param name="vmName"> The name of the virtual machine. </param>
 437        /// <param name="cancellationToken"> The cancellation token to use. </param>
 438        public Response Delete(string resourceGroupName, string vmName, CancellationToken cancellationToken = default)
 439        {
 26440            if (resourceGroupName == null)
 441            {
 0442                throw new ArgumentNullException(nameof(resourceGroupName));
 443            }
 26444            if (vmName == null)
 445            {
 0446                throw new ArgumentNullException(nameof(vmName));
 447            }
 448
 26449            using var message = CreateDeleteRequest(resourceGroupName, vmName);
 26450            _pipeline.Send(message, cancellationToken);
 26451            switch (message.Response.Status)
 452            {
 453                case 200:
 454                case 202:
 455                case 204:
 26456                    return message.Response;
 457                default:
 0458                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 459            }
 26460        }
 461
 462        internal HttpMessage CreateGetRequest(string resourceGroupName, string vmName)
 463        {
 152464            var message = _pipeline.CreateMessage();
 152465            var request = message.Request;
 152466            request.Method = RequestMethod.Get;
 152467            var uri = new RawRequestUriBuilder();
 152468            uri.Reset(endpoint);
 152469            uri.AppendPath("/subscriptions/", false);
 152470            uri.AppendPath(subscriptionId, true);
 152471            uri.AppendPath("/resourceGroups/", false);
 152472            uri.AppendPath(resourceGroupName, true);
 152473            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 152474            uri.AppendPath(vmName, true);
 152475            uri.AppendQuery("$expand", "instanceView", true);
 152476            uri.AppendQuery("api-version", "2019-12-01", true);
 152477            request.Uri = uri;
 152478            return message;
 479        }
 480
 481        /// <summary> Retrieves information about the model view or the instance view of a virtual machine. </summary>
 482        /// <param name="resourceGroupName"> The name of the resource group. </param>
 483        /// <param name="vmName"> The name of the virtual machine. </param>
 484        /// <param name="cancellationToken"> The cancellation token to use. </param>
 485        public async Task<Response<VirtualMachine>> GetAsync(string resourceGroupName, string vmName, CancellationToken 
 486        {
 76487            if (resourceGroupName == null)
 488            {
 0489                throw new ArgumentNullException(nameof(resourceGroupName));
 490            }
 76491            if (vmName == null)
 492            {
 0493                throw new ArgumentNullException(nameof(vmName));
 494            }
 495
 76496            using var message = CreateGetRequest(resourceGroupName, vmName);
 76497            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 76498            switch (message.Response.Status)
 499            {
 500                case 200:
 501                    {
 76502                        VirtualMachine value = default;
 76503                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 76504                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 505                        {
 0506                            value = null;
 507                        }
 508                        else
 509                        {
 76510                            value = VirtualMachine.DeserializeVirtualMachine(document.RootElement);
 511                        }
 76512                        return Response.FromValue(value, message.Response);
 513                    }
 514                default:
 0515                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 516            }
 76517        }
 518
 519        /// <summary> Retrieves information about the model view or the instance view of a virtual machine. </summary>
 520        /// <param name="resourceGroupName"> The name of the resource group. </param>
 521        /// <param name="vmName"> The name of the virtual machine. </param>
 522        /// <param name="cancellationToken"> The cancellation token to use. </param>
 523        public Response<VirtualMachine> Get(string resourceGroupName, string vmName, CancellationToken cancellationToken
 524        {
 76525            if (resourceGroupName == null)
 526            {
 0527                throw new ArgumentNullException(nameof(resourceGroupName));
 528            }
 76529            if (vmName == null)
 530            {
 0531                throw new ArgumentNullException(nameof(vmName));
 532            }
 533
 76534            using var message = CreateGetRequest(resourceGroupName, vmName);
 76535            _pipeline.Send(message, cancellationToken);
 76536            switch (message.Response.Status)
 537            {
 538                case 200:
 539                    {
 76540                        VirtualMachine value = default;
 76541                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 76542                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 543                        {
 0544                            value = null;
 545                        }
 546                        else
 547                        {
 76548                            value = VirtualMachine.DeserializeVirtualMachine(document.RootElement);
 549                        }
 76550                        return Response.FromValue(value, message.Response);
 551                    }
 552                default:
 0553                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 554            }
 76555        }
 556
 557        internal HttpMessage CreateInstanceViewRequest(string resourceGroupName, string vmName)
 558        {
 16559            var message = _pipeline.CreateMessage();
 16560            var request = message.Request;
 16561            request.Method = RequestMethod.Get;
 16562            var uri = new RawRequestUriBuilder();
 16563            uri.Reset(endpoint);
 16564            uri.AppendPath("/subscriptions/", false);
 16565            uri.AppendPath(subscriptionId, true);
 16566            uri.AppendPath("/resourceGroups/", false);
 16567            uri.AppendPath(resourceGroupName, true);
 16568            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 16569            uri.AppendPath(vmName, true);
 16570            uri.AppendPath("/instanceView", false);
 16571            uri.AppendQuery("api-version", "2019-12-01", true);
 16572            request.Uri = uri;
 16573            return message;
 574        }
 575
 576        /// <summary> Retrieves information about the run-time state of a virtual machine. </summary>
 577        /// <param name="resourceGroupName"> The name of the resource group. </param>
 578        /// <param name="vmName"> The name of the virtual machine. </param>
 579        /// <param name="cancellationToken"> The cancellation token to use. </param>
 580        public async Task<Response<VirtualMachineInstanceView>> InstanceViewAsync(string resourceGroupName, string vmNam
 581        {
 8582            if (resourceGroupName == null)
 583            {
 0584                throw new ArgumentNullException(nameof(resourceGroupName));
 585            }
 8586            if (vmName == null)
 587            {
 0588                throw new ArgumentNullException(nameof(vmName));
 589            }
 590
 8591            using var message = CreateInstanceViewRequest(resourceGroupName, vmName);
 8592            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8593            switch (message.Response.Status)
 594            {
 595                case 200:
 596                    {
 8597                        VirtualMachineInstanceView value = default;
 8598                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8599                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 600                        {
 0601                            value = null;
 602                        }
 603                        else
 604                        {
 8605                            value = VirtualMachineInstanceView.DeserializeVirtualMachineInstanceView(document.RootElemen
 606                        }
 8607                        return Response.FromValue(value, message.Response);
 608                    }
 609                default:
 0610                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 611            }
 8612        }
 613
 614        /// <summary> Retrieves information about the run-time state of a virtual machine. </summary>
 615        /// <param name="resourceGroupName"> The name of the resource group. </param>
 616        /// <param name="vmName"> The name of the virtual machine. </param>
 617        /// <param name="cancellationToken"> The cancellation token to use. </param>
 618        public Response<VirtualMachineInstanceView> InstanceView(string resourceGroupName, string vmName, CancellationTo
 619        {
 8620            if (resourceGroupName == null)
 621            {
 0622                throw new ArgumentNullException(nameof(resourceGroupName));
 623            }
 8624            if (vmName == null)
 625            {
 0626                throw new ArgumentNullException(nameof(vmName));
 627            }
 628
 8629            using var message = CreateInstanceViewRequest(resourceGroupName, vmName);
 8630            _pipeline.Send(message, cancellationToken);
 8631            switch (message.Response.Status)
 632            {
 633                case 200:
 634                    {
 8635                        VirtualMachineInstanceView value = default;
 8636                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8637                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 638                        {
 0639                            value = null;
 640                        }
 641                        else
 642                        {
 8643                            value = VirtualMachineInstanceView.DeserializeVirtualMachineInstanceView(document.RootElemen
 644                        }
 8645                        return Response.FromValue(value, message.Response);
 646                    }
 647                default:
 0648                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 649            }
 8650        }
 651
 652        internal HttpMessage CreateConvertToManagedDisksRequest(string resourceGroupName, string vmName)
 653        {
 0654            var message = _pipeline.CreateMessage();
 0655            var request = message.Request;
 0656            request.Method = RequestMethod.Post;
 0657            var uri = new RawRequestUriBuilder();
 0658            uri.Reset(endpoint);
 0659            uri.AppendPath("/subscriptions/", false);
 0660            uri.AppendPath(subscriptionId, true);
 0661            uri.AppendPath("/resourceGroups/", false);
 0662            uri.AppendPath(resourceGroupName, true);
 0663            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 0664            uri.AppendPath(vmName, true);
 0665            uri.AppendPath("/convertToManagedDisks", false);
 0666            uri.AppendQuery("api-version", "2019-12-01", true);
 0667            request.Uri = uri;
 0668            return message;
 669        }
 670
 671        /// <summary> Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deal
 672        /// <param name="resourceGroupName"> The name of the resource group. </param>
 673        /// <param name="vmName"> The name of the virtual machine. </param>
 674        /// <param name="cancellationToken"> The cancellation token to use. </param>
 675        public async Task<Response> ConvertToManagedDisksAsync(string resourceGroupName, string vmName, CancellationToke
 676        {
 0677            if (resourceGroupName == null)
 678            {
 0679                throw new ArgumentNullException(nameof(resourceGroupName));
 680            }
 0681            if (vmName == null)
 682            {
 0683                throw new ArgumentNullException(nameof(vmName));
 684            }
 685
 0686            using var message = CreateConvertToManagedDisksRequest(resourceGroupName, vmName);
 0687            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0688            switch (message.Response.Status)
 689            {
 690                case 200:
 691                case 202:
 0692                    return message.Response;
 693                default:
 0694                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 695            }
 0696        }
 697
 698        /// <summary> Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deal
 699        /// <param name="resourceGroupName"> The name of the resource group. </param>
 700        /// <param name="vmName"> The name of the virtual machine. </param>
 701        /// <param name="cancellationToken"> The cancellation token to use. </param>
 702        public Response ConvertToManagedDisks(string resourceGroupName, string vmName, CancellationToken cancellationTok
 703        {
 0704            if (resourceGroupName == null)
 705            {
 0706                throw new ArgumentNullException(nameof(resourceGroupName));
 707            }
 0708            if (vmName == null)
 709            {
 0710                throw new ArgumentNullException(nameof(vmName));
 711            }
 712
 0713            using var message = CreateConvertToManagedDisksRequest(resourceGroupName, vmName);
 0714            _pipeline.Send(message, cancellationToken);
 0715            switch (message.Response.Status)
 716            {
 717                case 200:
 718                case 202:
 0719                    return message.Response;
 720                default:
 0721                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 722            }
 0723        }
 724
 725        internal HttpMessage CreateDeallocateRequest(string resourceGroupName, string vmName)
 726        {
 8727            var message = _pipeline.CreateMessage();
 8728            var request = message.Request;
 8729            request.Method = RequestMethod.Post;
 8730            var uri = new RawRequestUriBuilder();
 8731            uri.Reset(endpoint);
 8732            uri.AppendPath("/subscriptions/", false);
 8733            uri.AppendPath(subscriptionId, true);
 8734            uri.AppendPath("/resourceGroups/", false);
 8735            uri.AppendPath(resourceGroupName, true);
 8736            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 8737            uri.AppendPath(vmName, true);
 8738            uri.AppendPath("/deallocate", false);
 8739            uri.AppendQuery("api-version", "2019-12-01", true);
 8740            request.Uri = uri;
 8741            return message;
 742        }
 743
 744        /// <summary> Shuts down the virtual machine and releases the compute resources. You are not billed for the comp
 745        /// <param name="resourceGroupName"> The name of the resource group. </param>
 746        /// <param name="vmName"> The name of the virtual machine. </param>
 747        /// <param name="cancellationToken"> The cancellation token to use. </param>
 748        public async Task<Response> DeallocateAsync(string resourceGroupName, string vmName, CancellationToken cancellat
 749        {
 2750            if (resourceGroupName == null)
 751            {
 0752                throw new ArgumentNullException(nameof(resourceGroupName));
 753            }
 2754            if (vmName == null)
 755            {
 0756                throw new ArgumentNullException(nameof(vmName));
 757            }
 758
 2759            using var message = CreateDeallocateRequest(resourceGroupName, vmName);
 2760            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2761            switch (message.Response.Status)
 762            {
 763                case 200:
 764                case 202:
 2765                    return message.Response;
 766                default:
 0767                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 768            }
 2769        }
 770
 771        /// <summary> Shuts down the virtual machine and releases the compute resources. You are not billed for the comp
 772        /// <param name="resourceGroupName"> The name of the resource group. </param>
 773        /// <param name="vmName"> The name of the virtual machine. </param>
 774        /// <param name="cancellationToken"> The cancellation token to use. </param>
 775        public Response Deallocate(string resourceGroupName, string vmName, CancellationToken cancellationToken = defaul
 776        {
 2777            if (resourceGroupName == null)
 778            {
 0779                throw new ArgumentNullException(nameof(resourceGroupName));
 780            }
 2781            if (vmName == null)
 782            {
 0783                throw new ArgumentNullException(nameof(vmName));
 784            }
 785
 2786            using var message = CreateDeallocateRequest(resourceGroupName, vmName);
 2787            _pipeline.Send(message, cancellationToken);
 2788            switch (message.Response.Status)
 789            {
 790                case 200:
 791                case 202:
 2792                    return message.Response;
 793                default:
 0794                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 795            }
 2796        }
 797
 798        internal HttpMessage CreateGeneralizeRequest(string resourceGroupName, string vmName)
 799        {
 0800            var message = _pipeline.CreateMessage();
 0801            var request = message.Request;
 0802            request.Method = RequestMethod.Post;
 0803            var uri = new RawRequestUriBuilder();
 0804            uri.Reset(endpoint);
 0805            uri.AppendPath("/subscriptions/", false);
 0806            uri.AppendPath(subscriptionId, true);
 0807            uri.AppendPath("/resourceGroups/", false);
 0808            uri.AppendPath(resourceGroupName, true);
 0809            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 0810            uri.AppendPath(vmName, true);
 0811            uri.AppendPath("/generalize", false);
 0812            uri.AppendQuery("api-version", "2019-12-01", true);
 0813            request.Uri = uri;
 0814            return message;
 815        }
 816
 817        /// <summary> Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the virtual 
 818        /// <param name="resourceGroupName"> The name of the resource group. </param>
 819        /// <param name="vmName"> The name of the virtual machine. </param>
 820        /// <param name="cancellationToken"> The cancellation token to use. </param>
 821        public async Task<Response> GeneralizeAsync(string resourceGroupName, string vmName, CancellationToken cancellat
 822        {
 0823            if (resourceGroupName == null)
 824            {
 0825                throw new ArgumentNullException(nameof(resourceGroupName));
 826            }
 0827            if (vmName == null)
 828            {
 0829                throw new ArgumentNullException(nameof(vmName));
 830            }
 831
 0832            using var message = CreateGeneralizeRequest(resourceGroupName, vmName);
 0833            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0834            switch (message.Response.Status)
 835            {
 836                case 200:
 0837                    return message.Response;
 838                default:
 0839                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 840            }
 0841        }
 842
 843        /// <summary> Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the virtual 
 844        /// <param name="resourceGroupName"> The name of the resource group. </param>
 845        /// <param name="vmName"> The name of the virtual machine. </param>
 846        /// <param name="cancellationToken"> The cancellation token to use. </param>
 847        public Response Generalize(string resourceGroupName, string vmName, CancellationToken cancellationToken = defaul
 848        {
 0849            if (resourceGroupName == null)
 850            {
 0851                throw new ArgumentNullException(nameof(resourceGroupName));
 852            }
 0853            if (vmName == null)
 854            {
 0855                throw new ArgumentNullException(nameof(vmName));
 856            }
 857
 0858            using var message = CreateGeneralizeRequest(resourceGroupName, vmName);
 0859            _pipeline.Send(message, cancellationToken);
 0860            switch (message.Response.Status)
 861            {
 862                case 200:
 0863                    return message.Response;
 864                default:
 0865                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 866            }
 0867        }
 868
 869        internal HttpMessage CreateListRequest(string resourceGroupName)
 870        {
 16871            var message = _pipeline.CreateMessage();
 16872            var request = message.Request;
 16873            request.Method = RequestMethod.Get;
 16874            var uri = new RawRequestUriBuilder();
 16875            uri.Reset(endpoint);
 16876            uri.AppendPath("/subscriptions/", false);
 16877            uri.AppendPath(subscriptionId, true);
 16878            uri.AppendPath("/resourceGroups/", false);
 16879            uri.AppendPath(resourceGroupName, true);
 16880            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines", false);
 16881            uri.AppendQuery("api-version", "2019-12-01", true);
 16882            request.Uri = uri;
 16883            return message;
 884        }
 885
 886        /// <summary> Lists all of the virtual machines in the specified resource group. Use the nextLink property in th
 887        /// <param name="resourceGroupName"> The name of the resource group. </param>
 888        /// <param name="cancellationToken"> The cancellation token to use. </param>
 889        public async Task<Response<VirtualMachineListResult>> ListAsync(string resourceGroupName, CancellationToken canc
 890        {
 8891            if (resourceGroupName == null)
 892            {
 0893                throw new ArgumentNullException(nameof(resourceGroupName));
 894            }
 895
 8896            using var message = CreateListRequest(resourceGroupName);
 8897            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8898            switch (message.Response.Status)
 899            {
 900                case 200:
 901                    {
 8902                        VirtualMachineListResult value = default;
 8903                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8904                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 905                        {
 0906                            value = null;
 907                        }
 908                        else
 909                        {
 8910                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 911                        }
 8912                        return Response.FromValue(value, message.Response);
 913                    }
 914                default:
 0915                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 916            }
 8917        }
 918
 919        /// <summary> Lists all of the virtual machines in the specified resource group. Use the nextLink property in th
 920        /// <param name="resourceGroupName"> The name of the resource group. </param>
 921        /// <param name="cancellationToken"> The cancellation token to use. </param>
 922        public Response<VirtualMachineListResult> List(string resourceGroupName, CancellationToken cancellationToken = d
 923        {
 8924            if (resourceGroupName == null)
 925            {
 0926                throw new ArgumentNullException(nameof(resourceGroupName));
 927            }
 928
 8929            using var message = CreateListRequest(resourceGroupName);
 8930            _pipeline.Send(message, cancellationToken);
 8931            switch (message.Response.Status)
 932            {
 933                case 200:
 934                    {
 8935                        VirtualMachineListResult value = default;
 8936                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8937                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 938                        {
 0939                            value = null;
 940                        }
 941                        else
 942                        {
 8943                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 944                        }
 8945                        return Response.FromValue(value, message.Response);
 946                    }
 947                default:
 0948                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 949            }
 8950        }
 951
 952        internal HttpMessage CreateListAllRequest(string statusOnly)
 953        {
 20954            var message = _pipeline.CreateMessage();
 20955            var request = message.Request;
 20956            request.Method = RequestMethod.Get;
 20957            var uri = new RawRequestUriBuilder();
 20958            uri.Reset(endpoint);
 20959            uri.AppendPath("/subscriptions/", false);
 20960            uri.AppendPath(subscriptionId, true);
 20961            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines", false);
 20962            uri.AppendQuery("api-version", "2019-12-01", true);
 20963            if (statusOnly != null)
 964            {
 0965                uri.AppendQuery("statusOnly", statusOnly, true);
 966            }
 20967            request.Uri = uri;
 20968            return message;
 969        }
 970
 971        /// <summary> Lists all of the virtual machines in the specified subscription. Use the nextLink property in the 
 972        /// <param name="statusOnly"> statusOnly=true enables fetching run time status of all Virtual Machines in the su
 973        /// <param name="cancellationToken"> The cancellation token to use. </param>
 974        public async Task<Response<VirtualMachineListResult>> ListAllAsync(string statusOnly = null, CancellationToken c
 975        {
 10976            using var message = CreateListAllRequest(statusOnly);
 10977            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 10978            switch (message.Response.Status)
 979            {
 980                case 200:
 981                    {
 10982                        VirtualMachineListResult value = default;
 10983                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 10984                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 985                        {
 0986                            value = null;
 987                        }
 988                        else
 989                        {
 10990                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 991                        }
 10992                        return Response.FromValue(value, message.Response);
 993                    }
 994                default:
 0995                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 996            }
 10997        }
 998
 999        /// <summary> Lists all of the virtual machines in the specified subscription. Use the nextLink property in the 
 1000        /// <param name="statusOnly"> statusOnly=true enables fetching run time status of all Virtual Machines in the su
 1001        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1002        public Response<VirtualMachineListResult> ListAll(string statusOnly = null, CancellationToken cancellationToken 
 1003        {
 101004            using var message = CreateListAllRequest(statusOnly);
 101005            _pipeline.Send(message, cancellationToken);
 101006            switch (message.Response.Status)
 1007            {
 1008                case 200:
 1009                    {
 101010                        VirtualMachineListResult value = default;
 101011                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 101012                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1013                        {
 01014                            value = null;
 1015                        }
 1016                        else
 1017                        {
 101018                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 1019                        }
 101020                        return Response.FromValue(value, message.Response);
 1021                    }
 1022                default:
 01023                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1024            }
 101025        }
 1026
 1027        internal HttpMessage CreateListAvailableSizesRequest(string resourceGroupName, string vmName)
 1028        {
 161029            var message = _pipeline.CreateMessage();
 161030            var request = message.Request;
 161031            request.Method = RequestMethod.Get;
 161032            var uri = new RawRequestUriBuilder();
 161033            uri.Reset(endpoint);
 161034            uri.AppendPath("/subscriptions/", false);
 161035            uri.AppendPath(subscriptionId, true);
 161036            uri.AppendPath("/resourceGroups/", false);
 161037            uri.AppendPath(resourceGroupName, true);
 161038            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 161039            uri.AppendPath(vmName, true);
 161040            uri.AppendPath("/vmSizes", false);
 161041            uri.AppendQuery("api-version", "2019-12-01", true);
 161042            request.Uri = uri;
 161043            return message;
 1044        }
 1045
 1046        /// <summary> Lists all available virtual machine sizes to which the specified virtual machine can be resized. <
 1047        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1048        /// <param name="vmName"> The name of the virtual machine. </param>
 1049        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1050        public async Task<Response<VirtualMachineSizeListResult>> ListAvailableSizesAsync(string resourceGroupName, stri
 1051        {
 81052            if (resourceGroupName == null)
 1053            {
 01054                throw new ArgumentNullException(nameof(resourceGroupName));
 1055            }
 81056            if (vmName == null)
 1057            {
 01058                throw new ArgumentNullException(nameof(vmName));
 1059            }
 1060
 81061            using var message = CreateListAvailableSizesRequest(resourceGroupName, vmName);
 81062            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 81063            switch (message.Response.Status)
 1064            {
 1065                case 200:
 1066                    {
 81067                        VirtualMachineSizeListResult value = default;
 81068                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 81069                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1070                        {
 01071                            value = null;
 1072                        }
 1073                        else
 1074                        {
 81075                            value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl
 1076                        }
 81077                        return Response.FromValue(value, message.Response);
 1078                    }
 1079                default:
 01080                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1081            }
 81082        }
 1083
 1084        /// <summary> Lists all available virtual machine sizes to which the specified virtual machine can be resized. <
 1085        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1086        /// <param name="vmName"> The name of the virtual machine. </param>
 1087        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1088        public Response<VirtualMachineSizeListResult> ListAvailableSizes(string resourceGroupName, string vmName, Cancel
 1089        {
 81090            if (resourceGroupName == null)
 1091            {
 01092                throw new ArgumentNullException(nameof(resourceGroupName));
 1093            }
 81094            if (vmName == null)
 1095            {
 01096                throw new ArgumentNullException(nameof(vmName));
 1097            }
 1098
 81099            using var message = CreateListAvailableSizesRequest(resourceGroupName, vmName);
 81100            _pipeline.Send(message, cancellationToken);
 81101            switch (message.Response.Status)
 1102            {
 1103                case 200:
 1104                    {
 81105                        VirtualMachineSizeListResult value = default;
 81106                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 81107                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1108                        {
 01109                            value = null;
 1110                        }
 1111                        else
 1112                        {
 81113                            value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl
 1114                        }
 81115                        return Response.FromValue(value, message.Response);
 1116                    }
 1117                default:
 01118                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1119            }
 81120        }
 1121
 1122        internal HttpMessage CreatePowerOffRequest(string resourceGroupName, string vmName, bool? skipShutdown)
 1123        {
 81124            var message = _pipeline.CreateMessage();
 81125            var request = message.Request;
 81126            request.Method = RequestMethod.Post;
 81127            var uri = new RawRequestUriBuilder();
 81128            uri.Reset(endpoint);
 81129            uri.AppendPath("/subscriptions/", false);
 81130            uri.AppendPath(subscriptionId, true);
 81131            uri.AppendPath("/resourceGroups/", false);
 81132            uri.AppendPath(resourceGroupName, true);
 81133            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 81134            uri.AppendPath(vmName, true);
 81135            uri.AppendPath("/powerOff", false);
 81136            if (skipShutdown != null)
 1137            {
 81138                uri.AppendQuery("skipShutdown", skipShutdown.Value, true);
 1139            }
 81140            uri.AppendQuery("api-version", "2019-12-01", true);
 81141            request.Uri = uri;
 81142            return message;
 1143        }
 1144
 1145        /// <summary> The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the
 1146        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1147        /// <param name="vmName"> The name of the virtual machine. </param>
 1148        /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi
 1149        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1150        public async Task<Response> PowerOffAsync(string resourceGroupName, string vmName, bool? skipShutdown = null, Ca
 1151        {
 21152            if (resourceGroupName == null)
 1153            {
 01154                throw new ArgumentNullException(nameof(resourceGroupName));
 1155            }
 21156            if (vmName == null)
 1157            {
 01158                throw new ArgumentNullException(nameof(vmName));
 1159            }
 1160
 21161            using var message = CreatePowerOffRequest(resourceGroupName, vmName, skipShutdown);
 21162            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21163            switch (message.Response.Status)
 1164            {
 1165                case 200:
 1166                case 202:
 21167                    return message.Response;
 1168                default:
 01169                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1170            }
 21171        }
 1172
 1173        /// <summary> The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the
 1174        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1175        /// <param name="vmName"> The name of the virtual machine. </param>
 1176        /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi
 1177        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1178        public Response PowerOff(string resourceGroupName, string vmName, bool? skipShutdown = null, CancellationToken c
 1179        {
 21180            if (resourceGroupName == null)
 1181            {
 01182                throw new ArgumentNullException(nameof(resourceGroupName));
 1183            }
 21184            if (vmName == null)
 1185            {
 01186                throw new ArgumentNullException(nameof(vmName));
 1187            }
 1188
 21189            using var message = CreatePowerOffRequest(resourceGroupName, vmName, skipShutdown);
 21190            _pipeline.Send(message, cancellationToken);
 21191            switch (message.Response.Status)
 1192            {
 1193                case 200:
 1194                case 202:
 21195                    return message.Response;
 1196                default:
 01197                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1198            }
 21199        }
 1200
 1201        internal HttpMessage CreateReapplyRequest(string resourceGroupName, string vmName)
 1202        {
 161203            var message = _pipeline.CreateMessage();
 161204            var request = message.Request;
 161205            request.Method = RequestMethod.Post;
 161206            var uri = new RawRequestUriBuilder();
 161207            uri.Reset(endpoint);
 161208            uri.AppendPath("/subscriptions/", false);
 161209            uri.AppendPath(subscriptionId, true);
 161210            uri.AppendPath("/resourceGroups/", false);
 161211            uri.AppendPath(resourceGroupName, true);
 161212            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 161213            uri.AppendPath(vmName, true);
 161214            uri.AppendPath("/reapply", false);
 161215            uri.AppendQuery("api-version", "2019-12-01", true);
 161216            request.Uri = uri;
 161217            return message;
 1218        }
 1219
 1220        /// <summary> The operation to reapply a virtual machine&apos;s state. </summary>
 1221        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1222        /// <param name="vmName"> The name of the virtual machine. </param>
 1223        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1224        public async Task<Response> ReapplyAsync(string resourceGroupName, string vmName, CancellationToken cancellation
 1225        {
 41226            if (resourceGroupName == null)
 1227            {
 01228                throw new ArgumentNullException(nameof(resourceGroupName));
 1229            }
 41230            if (vmName == null)
 1231            {
 01232                throw new ArgumentNullException(nameof(vmName));
 1233            }
 1234
 41235            using var message = CreateReapplyRequest(resourceGroupName, vmName);
 41236            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 41237            switch (message.Response.Status)
 1238            {
 1239                case 200:
 1240                case 202:
 41241                    return message.Response;
 1242                default:
 01243                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1244            }
 41245        }
 1246
 1247        /// <summary> The operation to reapply a virtual machine&apos;s state. </summary>
 1248        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1249        /// <param name="vmName"> The name of the virtual machine. </param>
 1250        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1251        public Response Reapply(string resourceGroupName, string vmName, CancellationToken cancellationToken = default)
 1252        {
 41253            if (resourceGroupName == null)
 1254            {
 01255                throw new ArgumentNullException(nameof(resourceGroupName));
 1256            }
 41257            if (vmName == null)
 1258            {
 01259                throw new ArgumentNullException(nameof(vmName));
 1260            }
 1261
 41262            using var message = CreateReapplyRequest(resourceGroupName, vmName);
 41263            _pipeline.Send(message, cancellationToken);
 41264            switch (message.Response.Status)
 1265            {
 1266                case 200:
 1267                case 202:
 41268                    return message.Response;
 1269                default:
 01270                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1271            }
 41272        }
 1273
 1274        internal HttpMessage CreateRestartRequest(string resourceGroupName, string vmName)
 1275        {
 01276            var message = _pipeline.CreateMessage();
 01277            var request = message.Request;
 01278            request.Method = RequestMethod.Post;
 01279            var uri = new RawRequestUriBuilder();
 01280            uri.Reset(endpoint);
 01281            uri.AppendPath("/subscriptions/", false);
 01282            uri.AppendPath(subscriptionId, true);
 01283            uri.AppendPath("/resourceGroups/", false);
 01284            uri.AppendPath(resourceGroupName, true);
 01285            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 01286            uri.AppendPath(vmName, true);
 01287            uri.AppendPath("/restart", false);
 01288            uri.AppendQuery("api-version", "2019-12-01", true);
 01289            request.Uri = uri;
 01290            return message;
 1291        }
 1292
 1293        /// <summary> The operation to restart a virtual machine. </summary>
 1294        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1295        /// <param name="vmName"> The name of the virtual machine. </param>
 1296        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1297        public async Task<Response> RestartAsync(string resourceGroupName, string vmName, CancellationToken cancellation
 1298        {
 01299            if (resourceGroupName == null)
 1300            {
 01301                throw new ArgumentNullException(nameof(resourceGroupName));
 1302            }
 01303            if (vmName == null)
 1304            {
 01305                throw new ArgumentNullException(nameof(vmName));
 1306            }
 1307
 01308            using var message = CreateRestartRequest(resourceGroupName, vmName);
 01309            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01310            switch (message.Response.Status)
 1311            {
 1312                case 200:
 1313                case 202:
 01314                    return message.Response;
 1315                default:
 01316                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1317            }
 01318        }
 1319
 1320        /// <summary> The operation to restart a virtual machine. </summary>
 1321        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1322        /// <param name="vmName"> The name of the virtual machine. </param>
 1323        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1324        public Response Restart(string resourceGroupName, string vmName, CancellationToken cancellationToken = default)
 1325        {
 01326            if (resourceGroupName == null)
 1327            {
 01328                throw new ArgumentNullException(nameof(resourceGroupName));
 1329            }
 01330            if (vmName == null)
 1331            {
 01332                throw new ArgumentNullException(nameof(vmName));
 1333            }
 1334
 01335            using var message = CreateRestartRequest(resourceGroupName, vmName);
 01336            _pipeline.Send(message, cancellationToken);
 01337            switch (message.Response.Status)
 1338            {
 1339                case 200:
 1340                case 202:
 01341                    return message.Response;
 1342                default:
 01343                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1344            }
 01345        }
 1346
 1347        internal HttpMessage CreateStartRequest(string resourceGroupName, string vmName)
 1348        {
 161349            var message = _pipeline.CreateMessage();
 161350            var request = message.Request;
 161351            request.Method = RequestMethod.Post;
 161352            var uri = new RawRequestUriBuilder();
 161353            uri.Reset(endpoint);
 161354            uri.AppendPath("/subscriptions/", false);
 161355            uri.AppendPath(subscriptionId, true);
 161356            uri.AppendPath("/resourceGroups/", false);
 161357            uri.AppendPath(resourceGroupName, true);
 161358            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 161359            uri.AppendPath(vmName, true);
 161360            uri.AppendPath("/start", false);
 161361            uri.AppendQuery("api-version", "2019-12-01", true);
 161362            request.Uri = uri;
 161363            return message;
 1364        }
 1365
 1366        /// <summary> The operation to start a virtual machine. </summary>
 1367        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1368        /// <param name="vmName"> The name of the virtual machine. </param>
 1369        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1370        public async Task<Response> StartAsync(string resourceGroupName, string vmName, CancellationToken cancellationTo
 1371        {
 41372            if (resourceGroupName == null)
 1373            {
 01374                throw new ArgumentNullException(nameof(resourceGroupName));
 1375            }
 41376            if (vmName == null)
 1377            {
 01378                throw new ArgumentNullException(nameof(vmName));
 1379            }
 1380
 41381            using var message = CreateStartRequest(resourceGroupName, vmName);
 41382            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 41383            switch (message.Response.Status)
 1384            {
 1385                case 200:
 1386                case 202:
 41387                    return message.Response;
 1388                default:
 01389                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1390            }
 41391        }
 1392
 1393        /// <summary> The operation to start a virtual machine. </summary>
 1394        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1395        /// <param name="vmName"> The name of the virtual machine. </param>
 1396        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1397        public Response Start(string resourceGroupName, string vmName, CancellationToken cancellationToken = default)
 1398        {
 41399            if (resourceGroupName == null)
 1400            {
 01401                throw new ArgumentNullException(nameof(resourceGroupName));
 1402            }
 41403            if (vmName == null)
 1404            {
 01405                throw new ArgumentNullException(nameof(vmName));
 1406            }
 1407
 41408            using var message = CreateStartRequest(resourceGroupName, vmName);
 41409            _pipeline.Send(message, cancellationToken);
 41410            switch (message.Response.Status)
 1411            {
 1412                case 200:
 1413                case 202:
 41414                    return message.Response;
 1415                default:
 01416                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1417            }
 41418        }
 1419
 1420        internal HttpMessage CreateRedeployRequest(string resourceGroupName, string vmName)
 1421        {
 161422            var message = _pipeline.CreateMessage();
 161423            var request = message.Request;
 161424            request.Method = RequestMethod.Post;
 161425            var uri = new RawRequestUriBuilder();
 161426            uri.Reset(endpoint);
 161427            uri.AppendPath("/subscriptions/", false);
 161428            uri.AppendPath(subscriptionId, true);
 161429            uri.AppendPath("/resourceGroups/", false);
 161430            uri.AppendPath(resourceGroupName, true);
 161431            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 161432            uri.AppendPath(vmName, true);
 161433            uri.AppendPath("/redeploy", false);
 161434            uri.AppendQuery("api-version", "2019-12-01", true);
 161435            request.Uri = uri;
 161436            return message;
 1437        }
 1438
 1439        /// <summary> Shuts down the virtual machine, moves it to a new node, and powers it back on. </summary>
 1440        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1441        /// <param name="vmName"> The name of the virtual machine. </param>
 1442        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1443        public async Task<Response> RedeployAsync(string resourceGroupName, string vmName, CancellationToken cancellatio
 1444        {
 41445            if (resourceGroupName == null)
 1446            {
 01447                throw new ArgumentNullException(nameof(resourceGroupName));
 1448            }
 41449            if (vmName == null)
 1450            {
 01451                throw new ArgumentNullException(nameof(vmName));
 1452            }
 1453
 41454            using var message = CreateRedeployRequest(resourceGroupName, vmName);
 41455            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 41456            switch (message.Response.Status)
 1457            {
 1458                case 200:
 1459                case 202:
 41460                    return message.Response;
 1461                default:
 01462                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1463            }
 41464        }
 1465
 1466        /// <summary> Shuts down the virtual machine, moves it to a new node, and powers it back on. </summary>
 1467        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1468        /// <param name="vmName"> The name of the virtual machine. </param>
 1469        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1470        public Response Redeploy(string resourceGroupName, string vmName, CancellationToken cancellationToken = default)
 1471        {
 41472            if (resourceGroupName == null)
 1473            {
 01474                throw new ArgumentNullException(nameof(resourceGroupName));
 1475            }
 41476            if (vmName == null)
 1477            {
 01478                throw new ArgumentNullException(nameof(vmName));
 1479            }
 1480
 41481            using var message = CreateRedeployRequest(resourceGroupName, vmName);
 41482            _pipeline.Send(message, cancellationToken);
 41483            switch (message.Response.Status)
 1484            {
 1485                case 200:
 1486                case 202:
 41487                    return message.Response;
 1488                default:
 01489                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1490            }
 41491        }
 1492
 1493        internal HttpMessage CreateReimageRequest(string resourceGroupName, string vmName, VirtualMachineReimageParamete
 1494        {
 01495            var message = _pipeline.CreateMessage();
 01496            var request = message.Request;
 01497            request.Method = RequestMethod.Post;
 01498            var uri = new RawRequestUriBuilder();
 01499            uri.Reset(endpoint);
 01500            uri.AppendPath("/subscriptions/", false);
 01501            uri.AppendPath(subscriptionId, true);
 01502            uri.AppendPath("/resourceGroups/", false);
 01503            uri.AppendPath(resourceGroupName, true);
 01504            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 01505            uri.AppendPath(vmName, true);
 01506            uri.AppendPath("/reimage", false);
 01507            uri.AppendQuery("api-version", "2019-12-01", true);
 01508            request.Uri = uri;
 01509            request.Headers.Add("Content-Type", "application/json");
 01510            if (parameters != null)
 1511            {
 01512                var content = new Utf8JsonRequestContent();
 01513                content.JsonWriter.WriteObjectValue(parameters);
 01514                request.Content = content;
 1515            }
 01516            return message;
 1517        }
 1518
 1519        /// <summary> Reimages the virtual machine which has an ephemeral OS disk back to its initial state. </summary>
 1520        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1521        /// <param name="vmName"> The name of the virtual machine. </param>
 1522        /// <param name="parameters"> Parameters supplied to the Reimage Virtual Machine operation. </param>
 1523        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1524        public async Task<Response> ReimageAsync(string resourceGroupName, string vmName, VirtualMachineReimageParameter
 1525        {
 01526            if (resourceGroupName == null)
 1527            {
 01528                throw new ArgumentNullException(nameof(resourceGroupName));
 1529            }
 01530            if (vmName == null)
 1531            {
 01532                throw new ArgumentNullException(nameof(vmName));
 1533            }
 1534
 01535            using var message = CreateReimageRequest(resourceGroupName, vmName, parameters);
 01536            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01537            switch (message.Response.Status)
 1538            {
 1539                case 200:
 1540                case 202:
 01541                    return message.Response;
 1542                default:
 01543                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1544            }
 01545        }
 1546
 1547        /// <summary> Reimages the virtual machine which has an ephemeral OS disk back to its initial state. </summary>
 1548        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1549        /// <param name="vmName"> The name of the virtual machine. </param>
 1550        /// <param name="parameters"> Parameters supplied to the Reimage Virtual Machine operation. </param>
 1551        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1552        public Response Reimage(string resourceGroupName, string vmName, VirtualMachineReimageParameters parameters = nu
 1553        {
 01554            if (resourceGroupName == null)
 1555            {
 01556                throw new ArgumentNullException(nameof(resourceGroupName));
 1557            }
 01558            if (vmName == null)
 1559            {
 01560                throw new ArgumentNullException(nameof(vmName));
 1561            }
 1562
 01563            using var message = CreateReimageRequest(resourceGroupName, vmName, parameters);
 01564            _pipeline.Send(message, cancellationToken);
 01565            switch (message.Response.Status)
 1566            {
 1567                case 200:
 1568                case 202:
 01569                    return message.Response;
 1570                default:
 01571                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1572            }
 01573        }
 1574
 1575        internal HttpMessage CreatePerformMaintenanceRequest(string resourceGroupName, string vmName)
 1576        {
 41577            var message = _pipeline.CreateMessage();
 41578            var request = message.Request;
 41579            request.Method = RequestMethod.Post;
 41580            var uri = new RawRequestUriBuilder();
 41581            uri.Reset(endpoint);
 41582            uri.AppendPath("/subscriptions/", false);
 41583            uri.AppendPath(subscriptionId, true);
 41584            uri.AppendPath("/resourceGroups/", false);
 41585            uri.AppendPath(resourceGroupName, true);
 41586            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 41587            uri.AppendPath(vmName, true);
 41588            uri.AppendPath("/performMaintenance", false);
 41589            uri.AppendQuery("api-version", "2019-12-01", true);
 41590            request.Uri = uri;
 41591            return message;
 1592        }
 1593
 1594        /// <summary> The operation to perform maintenance on a virtual machine. </summary>
 1595        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1596        /// <param name="vmName"> The name of the virtual machine. </param>
 1597        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1598        public async Task<Response> PerformMaintenanceAsync(string resourceGroupName, string vmName, CancellationToken c
 1599        {
 21600            if (resourceGroupName == null)
 1601            {
 01602                throw new ArgumentNullException(nameof(resourceGroupName));
 1603            }
 21604            if (vmName == null)
 1605            {
 01606                throw new ArgumentNullException(nameof(vmName));
 1607            }
 1608
 21609            using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmName);
 21610            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21611            switch (message.Response.Status)
 1612            {
 1613                case 200:
 1614                case 202:
 01615                    return message.Response;
 1616                default:
 21617                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1618            }
 01619        }
 1620
 1621        /// <summary> The operation to perform maintenance on a virtual machine. </summary>
 1622        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1623        /// <param name="vmName"> The name of the virtual machine. </param>
 1624        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1625        public Response PerformMaintenance(string resourceGroupName, string vmName, CancellationToken cancellationToken 
 1626        {
 21627            if (resourceGroupName == null)
 1628            {
 01629                throw new ArgumentNullException(nameof(resourceGroupName));
 1630            }
 21631            if (vmName == null)
 1632            {
 01633                throw new ArgumentNullException(nameof(vmName));
 1634            }
 1635
 21636            using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmName);
 21637            _pipeline.Send(message, cancellationToken);
 21638            switch (message.Response.Status)
 1639            {
 1640                case 200:
 1641                case 202:
 01642                    return message.Response;
 1643                default:
 21644                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1645            }
 01646        }
 1647
 1648        internal HttpMessage CreateSimulateEvictionRequest(string resourceGroupName, string vmName)
 1649        {
 41650            var message = _pipeline.CreateMessage();
 41651            var request = message.Request;
 41652            request.Method = RequestMethod.Post;
 41653            var uri = new RawRequestUriBuilder();
 41654            uri.Reset(endpoint);
 41655            uri.AppendPath("/subscriptions/", false);
 41656            uri.AppendPath(subscriptionId, true);
 41657            uri.AppendPath("/resourceGroups/", false);
 41658            uri.AppendPath(resourceGroupName, true);
 41659            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 41660            uri.AppendPath(vmName, true);
 41661            uri.AppendPath("/simulateEviction", false);
 41662            uri.AppendQuery("api-version", "2019-12-01", true);
 41663            request.Uri = uri;
 41664            return message;
 1665        }
 1666
 1667        /// <summary> The operation to simulate the eviction of spot virtual machine. The eviction will occur within 30 
 1668        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1669        /// <param name="vmName"> The name of the virtual machine. </param>
 1670        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1671        public async Task<Response> SimulateEvictionAsync(string resourceGroupName, string vmName, CancellationToken can
 1672        {
 21673            if (resourceGroupName == null)
 1674            {
 01675                throw new ArgumentNullException(nameof(resourceGroupName));
 1676            }
 21677            if (vmName == null)
 1678            {
 01679                throw new ArgumentNullException(nameof(vmName));
 1680            }
 1681
 21682            using var message = CreateSimulateEvictionRequest(resourceGroupName, vmName);
 21683            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21684            switch (message.Response.Status)
 1685            {
 1686                case 204:
 21687                    return message.Response;
 1688                default:
 01689                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1690            }
 21691        }
 1692
 1693        /// <summary> The operation to simulate the eviction of spot virtual machine. The eviction will occur within 30 
 1694        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1695        /// <param name="vmName"> The name of the virtual machine. </param>
 1696        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1697        public Response SimulateEviction(string resourceGroupName, string vmName, CancellationToken cancellationToken = 
 1698        {
 21699            if (resourceGroupName == null)
 1700            {
 01701                throw new ArgumentNullException(nameof(resourceGroupName));
 1702            }
 21703            if (vmName == null)
 1704            {
 01705                throw new ArgumentNullException(nameof(vmName));
 1706            }
 1707
 21708            using var message = CreateSimulateEvictionRequest(resourceGroupName, vmName);
 21709            _pipeline.Send(message, cancellationToken);
 21710            switch (message.Response.Status)
 1711            {
 1712                case 204:
 21713                    return message.Response;
 1714                default:
 01715                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1716            }
 21717        }
 1718
 1719        internal HttpMessage CreateRunCommandRequest(string resourceGroupName, string vmName, RunCommandInput parameters
 1720        {
 01721            var message = _pipeline.CreateMessage();
 01722            var request = message.Request;
 01723            request.Method = RequestMethod.Post;
 01724            var uri = new RawRequestUriBuilder();
 01725            uri.Reset(endpoint);
 01726            uri.AppendPath("/subscriptions/", false);
 01727            uri.AppendPath(subscriptionId, true);
 01728            uri.AppendPath("/resourceGroups/", false);
 01729            uri.AppendPath(resourceGroupName, true);
 01730            uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false);
 01731            uri.AppendPath(vmName, true);
 01732            uri.AppendPath("/runCommand", false);
 01733            uri.AppendQuery("api-version", "2019-12-01", true);
 01734            request.Uri = uri;
 01735            request.Headers.Add("Content-Type", "application/json");
 01736            var content = new Utf8JsonRequestContent();
 01737            content.JsonWriter.WriteObjectValue(parameters);
 01738            request.Content = content;
 01739            return message;
 1740        }
 1741
 1742        /// <summary> Run command on the VM. </summary>
 1743        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1744        /// <param name="vmName"> The name of the virtual machine. </param>
 1745        /// <param name="parameters"> Parameters supplied to the Run command operation. </param>
 1746        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1747        public async Task<Response> RunCommandAsync(string resourceGroupName, string vmName, RunCommandInput parameters,
 1748        {
 01749            if (resourceGroupName == null)
 1750            {
 01751                throw new ArgumentNullException(nameof(resourceGroupName));
 1752            }
 01753            if (vmName == null)
 1754            {
 01755                throw new ArgumentNullException(nameof(vmName));
 1756            }
 01757            if (parameters == null)
 1758            {
 01759                throw new ArgumentNullException(nameof(parameters));
 1760            }
 1761
 01762            using var message = CreateRunCommandRequest(resourceGroupName, vmName, parameters);
 01763            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01764            switch (message.Response.Status)
 1765            {
 1766                case 200:
 1767                case 202:
 01768                    return message.Response;
 1769                default:
 01770                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1771            }
 01772        }
 1773
 1774        /// <summary> Run command on the VM. </summary>
 1775        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1776        /// <param name="vmName"> The name of the virtual machine. </param>
 1777        /// <param name="parameters"> Parameters supplied to the Run command operation. </param>
 1778        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1779        public Response RunCommand(string resourceGroupName, string vmName, RunCommandInput parameters, CancellationToke
 1780        {
 01781            if (resourceGroupName == null)
 1782            {
 01783                throw new ArgumentNullException(nameof(resourceGroupName));
 1784            }
 01785            if (vmName == null)
 1786            {
 01787                throw new ArgumentNullException(nameof(vmName));
 1788            }
 01789            if (parameters == null)
 1790            {
 01791                throw new ArgumentNullException(nameof(parameters));
 1792            }
 1793
 01794            using var message = CreateRunCommandRequest(resourceGroupName, vmName, parameters);
 01795            _pipeline.Send(message, cancellationToken);
 01796            switch (message.Response.Status)
 1797            {
 1798                case 200:
 1799                case 202:
 01800                    return message.Response;
 1801                default:
 01802                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1803            }
 01804        }
 1805
 1806        internal HttpMessage CreateListByLocationNextPageRequest(string nextLink, string location)
 1807        {
 01808            var message = _pipeline.CreateMessage();
 01809            var request = message.Request;
 01810            request.Method = RequestMethod.Get;
 01811            var uri = new RawRequestUriBuilder();
 01812            uri.Reset(endpoint);
 01813            uri.AppendRawNextLink(nextLink, false);
 01814            request.Uri = uri;
 01815            return message;
 1816        }
 1817
 1818        /// <summary> Gets all the virtual machines under the specified subscription for the specified location. </summa
 1819        /// <param name="nextLink"> The URL to the next page of results. </param>
 1820        /// <param name="location"> The location for which virtual machines under the subscription are queried. </param>
 1821        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1822        public async Task<Response<VirtualMachineListResult>> ListByLocationNextPageAsync(string nextLink, string locati
 1823        {
 01824            if (nextLink == null)
 1825            {
 01826                throw new ArgumentNullException(nameof(nextLink));
 1827            }
 01828            if (location == null)
 1829            {
 01830                throw new ArgumentNullException(nameof(location));
 1831            }
 1832
 01833            using var message = CreateListByLocationNextPageRequest(nextLink, location);
 01834            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01835            switch (message.Response.Status)
 1836            {
 1837                case 200:
 1838                    {
 01839                        VirtualMachineListResult value = default;
 01840                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01841                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1842                        {
 01843                            value = null;
 1844                        }
 1845                        else
 1846                        {
 01847                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 1848                        }
 01849                        return Response.FromValue(value, message.Response);
 1850                    }
 1851                default:
 01852                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1853            }
 01854        }
 1855
 1856        /// <summary> Gets all the virtual machines under the specified subscription for the specified location. </summa
 1857        /// <param name="nextLink"> The URL to the next page of results. </param>
 1858        /// <param name="location"> The location for which virtual machines under the subscription are queried. </param>
 1859        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1860        public Response<VirtualMachineListResult> ListByLocationNextPage(string nextLink, string location, CancellationT
 1861        {
 01862            if (nextLink == null)
 1863            {
 01864                throw new ArgumentNullException(nameof(nextLink));
 1865            }
 01866            if (location == null)
 1867            {
 01868                throw new ArgumentNullException(nameof(location));
 1869            }
 1870
 01871            using var message = CreateListByLocationNextPageRequest(nextLink, location);
 01872            _pipeline.Send(message, cancellationToken);
 01873            switch (message.Response.Status)
 1874            {
 1875                case 200:
 1876                    {
 01877                        VirtualMachineListResult value = default;
 01878                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01879                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1880                        {
 01881                            value = null;
 1882                        }
 1883                        else
 1884                        {
 01885                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 1886                        }
 01887                        return Response.FromValue(value, message.Response);
 1888                    }
 1889                default:
 01890                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1891            }
 01892        }
 1893
 1894        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName)
 1895        {
 01896            var message = _pipeline.CreateMessage();
 01897            var request = message.Request;
 01898            request.Method = RequestMethod.Get;
 01899            var uri = new RawRequestUriBuilder();
 01900            uri.Reset(endpoint);
 01901            uri.AppendRawNextLink(nextLink, false);
 01902            request.Uri = uri;
 01903            return message;
 1904        }
 1905
 1906        /// <summary> Lists all of the virtual machines in the specified resource group. Use the nextLink property in th
 1907        /// <param name="nextLink"> The URL to the next page of results. </param>
 1908        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1909        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1910        public async Task<Response<VirtualMachineListResult>> ListNextPageAsync(string nextLink, string resourceGroupNam
 1911        {
 01912            if (nextLink == null)
 1913            {
 01914                throw new ArgumentNullException(nameof(nextLink));
 1915            }
 01916            if (resourceGroupName == null)
 1917            {
 01918                throw new ArgumentNullException(nameof(resourceGroupName));
 1919            }
 1920
 01921            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 01922            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01923            switch (message.Response.Status)
 1924            {
 1925                case 200:
 1926                    {
 01927                        VirtualMachineListResult value = default;
 01928                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01929                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1930                        {
 01931                            value = null;
 1932                        }
 1933                        else
 1934                        {
 01935                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 1936                        }
 01937                        return Response.FromValue(value, message.Response);
 1938                    }
 1939                default:
 01940                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1941            }
 01942        }
 1943
 1944        /// <summary> Lists all of the virtual machines in the specified resource group. Use the nextLink property in th
 1945        /// <param name="nextLink"> The URL to the next page of results. </param>
 1946        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1947        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1948        public Response<VirtualMachineListResult> ListNextPage(string nextLink, string resourceGroupName, CancellationTo
 1949        {
 01950            if (nextLink == null)
 1951            {
 01952                throw new ArgumentNullException(nameof(nextLink));
 1953            }
 01954            if (resourceGroupName == null)
 1955            {
 01956                throw new ArgumentNullException(nameof(resourceGroupName));
 1957            }
 1958
 01959            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 01960            _pipeline.Send(message, cancellationToken);
 01961            switch (message.Response.Status)
 1962            {
 1963                case 200:
 1964                    {
 01965                        VirtualMachineListResult value = default;
 01966                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01967                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1968                        {
 01969                            value = null;
 1970                        }
 1971                        else
 1972                        {
 01973                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 1974                        }
 01975                        return Response.FromValue(value, message.Response);
 1976                    }
 1977                default:
 01978                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1979            }
 01980        }
 1981
 1982        internal HttpMessage CreateListAllNextPageRequest(string nextLink, string statusOnly)
 1983        {
 01984            var message = _pipeline.CreateMessage();
 01985            var request = message.Request;
 01986            request.Method = RequestMethod.Get;
 01987            var uri = new RawRequestUriBuilder();
 01988            uri.Reset(endpoint);
 01989            uri.AppendRawNextLink(nextLink, false);
 01990            request.Uri = uri;
 01991            return message;
 1992        }
 1993
 1994        /// <summary> Lists all of the virtual machines in the specified subscription. Use the nextLink property in the 
 1995        /// <param name="nextLink"> The URL to the next page of results. </param>
 1996        /// <param name="statusOnly"> statusOnly=true enables fetching run time status of all Virtual Machines in the su
 1997        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1998        public async Task<Response<VirtualMachineListResult>> ListAllNextPageAsync(string nextLink, string statusOnly = 
 1999        {
 02000            if (nextLink == null)
 2001            {
 02002                throw new ArgumentNullException(nameof(nextLink));
 2003            }
 2004
 02005            using var message = CreateListAllNextPageRequest(nextLink, statusOnly);
 02006            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 02007            switch (message.Response.Status)
 2008            {
 2009                case 200:
 2010                    {
 02011                        VirtualMachineListResult value = default;
 02012                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 02013                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2014                        {
 02015                            value = null;
 2016                        }
 2017                        else
 2018                        {
 02019                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 2020                        }
 02021                        return Response.FromValue(value, message.Response);
 2022                    }
 2023                default:
 02024                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 2025            }
 02026        }
 2027
 2028        /// <summary> Lists all of the virtual machines in the specified subscription. Use the nextLink property in the 
 2029        /// <param name="nextLink"> The URL to the next page of results. </param>
 2030        /// <param name="statusOnly"> statusOnly=true enables fetching run time status of all Virtual Machines in the su
 2031        /// <param name="cancellationToken"> The cancellation token to use. </param>
 2032        public Response<VirtualMachineListResult> ListAllNextPage(string nextLink, string statusOnly = null, Cancellatio
 2033        {
 02034            if (nextLink == null)
 2035            {
 02036                throw new ArgumentNullException(nameof(nextLink));
 2037            }
 2038
 02039            using var message = CreateListAllNextPageRequest(nextLink, statusOnly);
 02040            _pipeline.Send(message, cancellationToken);
 02041            switch (message.Response.Status)
 2042            {
 2043                case 200:
 2044                    {
 02045                        VirtualMachineListResult value = default;
 02046                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 02047                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 2048                        {
 02049                            value = null;
 2050                        }
 2051                        else
 2052                        {
 02053                            value = VirtualMachineListResult.DeserializeVirtualMachineListResult(document.RootElement);
 2054                        }
 02055                        return Response.FromValue(value, message.Response);
 2056                    }
 2057                default:
 02058                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 2059            }
 02060        }
 2061    }
 2062}

Methods/Properties

.ctor(...)
CreateListByLocationRequest(...)
ListByLocationAsync()
ListByLocation(...)
CreateCaptureRequest(...)
CaptureAsync()
Capture(...)
CreateCreateOrUpdateRequest(...)
CreateOrUpdateAsync()
CreateOrUpdate(...)
CreateUpdateRequest(...)
UpdateAsync()
Update(...)
CreateDeleteRequest(...)
DeleteAsync()
Delete(...)
CreateGetRequest(...)
GetAsync()
Get(...)
CreateInstanceViewRequest(...)
InstanceViewAsync()
InstanceView(...)
CreateConvertToManagedDisksRequest(...)
ConvertToManagedDisksAsync()
ConvertToManagedDisks(...)
CreateDeallocateRequest(...)
DeallocateAsync()
Deallocate(...)
CreateGeneralizeRequest(...)
GeneralizeAsync()
Generalize(...)
CreateListRequest(...)
ListAsync()
List(...)
CreateListAllRequest(...)
ListAllAsync()
ListAll(...)
CreateListAvailableSizesRequest(...)
ListAvailableSizesAsync()
ListAvailableSizes(...)
CreatePowerOffRequest(...)
PowerOffAsync()
PowerOff(...)
CreateReapplyRequest(...)
ReapplyAsync()
Reapply(...)
CreateRestartRequest(...)
RestartAsync()
Restart(...)
CreateStartRequest(...)
StartAsync()
Start(...)
CreateRedeployRequest(...)
RedeployAsync()
Redeploy(...)
CreateReimageRequest(...)
ReimageAsync()
Reimage(...)
CreatePerformMaintenanceRequest(...)
PerformMaintenanceAsync()
PerformMaintenance(...)
CreateSimulateEvictionRequest(...)
SimulateEvictionAsync()
SimulateEviction(...)
CreateRunCommandRequest(...)
RunCommandAsync()
RunCommand(...)
CreateListByLocationNextPageRequest(...)
ListByLocationNextPageAsync()
ListByLocationNextPage(...)
CreateListNextPageRequest(...)
ListNextPageAsync()
ListNextPage(...)
CreateListAllNextPageRequest(...)
ListAllNextPageAsync()
ListAllNextPage(...)