| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Compute.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Compute |
| | 18 | | { |
| | 19 | | internal partial class VirtualMachineScaleSetVMsRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of VirtualMachineScaleSetVMsRestOperations. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 396 | 32 | | public VirtualMachineScaleSetVMsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, strin |
| | 33 | | { |
| 396 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 396 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 396 | 40 | | this.subscriptionId = subscriptionId; |
| 396 | 41 | | this.endpoint = endpoint; |
| 396 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 43 | | _pipeline = pipeline; |
| 396 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateReimageRequest(string resourceGroupName, string vmScaleSetName, string instanceId, Vi |
| | 47 | | { |
| 16 | 48 | | var message = _pipeline.CreateMessage(); |
| 16 | 49 | | var request = message.Request; |
| 16 | 50 | | request.Method = RequestMethod.Post; |
| 16 | 51 | | var uri = new RawRequestUriBuilder(); |
| 16 | 52 | | uri.Reset(endpoint); |
| 16 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 54 | | uri.AppendPath(subscriptionId, true); |
| 16 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 57 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 58 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 59 | | uri.AppendPath("/virtualmachines/", false); |
| 16 | 60 | | uri.AppendPath(instanceId, true); |
| 16 | 61 | | uri.AppendPath("/reimage", false); |
| 16 | 62 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 63 | | request.Uri = uri; |
| 16 | 64 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 65 | | if (vmScaleSetVMReimageInput != null) |
| | 66 | | { |
| 0 | 67 | | var content = new Utf8JsonRequestContent(); |
| 0 | 68 | | content.JsonWriter.WriteObjectValue(vmScaleSetVMReimageInput); |
| 0 | 69 | | request.Content = content; |
| | 70 | | } |
| 16 | 71 | | return message; |
| | 72 | | } |
| | 73 | |
|
| | 74 | | /// <summary> Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. </summary> |
| | 75 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 76 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 77 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 78 | | /// <param name="vmScaleSetVMReimageInput"> Parameters for the Reimaging Virtual machine in ScaleSet. </param> |
| | 79 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 80 | | public async Task<Response> ReimageAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Vir |
| | 81 | | { |
| 4 | 82 | | if (resourceGroupName == null) |
| | 83 | | { |
| 0 | 84 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 85 | | } |
| 4 | 86 | | if (vmScaleSetName == null) |
| | 87 | | { |
| 0 | 88 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 89 | | } |
| 4 | 90 | | if (instanceId == null) |
| | 91 | | { |
| 0 | 92 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 93 | | } |
| | 94 | |
|
| 4 | 95 | | using var message = CreateReimageRequest(resourceGroupName, vmScaleSetName, instanceId, vmScaleSetVMReimageI |
| 4 | 96 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 97 | | switch (message.Response.Status) |
| | 98 | | { |
| | 99 | | case 200: |
| | 100 | | case 202: |
| 4 | 101 | | return message.Response; |
| | 102 | | default: |
| 0 | 103 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 104 | | } |
| 4 | 105 | | } |
| | 106 | |
|
| | 107 | | /// <summary> Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. </summary> |
| | 108 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 109 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 110 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 111 | | /// <param name="vmScaleSetVMReimageInput"> Parameters for the Reimaging Virtual machine in ScaleSet. </param> |
| | 112 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 113 | | public Response Reimage(string resourceGroupName, string vmScaleSetName, string instanceId, VirtualMachineReimag |
| | 114 | | { |
| 4 | 115 | | if (resourceGroupName == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 118 | | } |
| 4 | 119 | | if (vmScaleSetName == null) |
| | 120 | | { |
| 0 | 121 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 122 | | } |
| 4 | 123 | | if (instanceId == null) |
| | 124 | | { |
| 0 | 125 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 126 | | } |
| | 127 | |
|
| 4 | 128 | | using var message = CreateReimageRequest(resourceGroupName, vmScaleSetName, instanceId, vmScaleSetVMReimageI |
| 4 | 129 | | _pipeline.Send(message, cancellationToken); |
| 4 | 130 | | switch (message.Response.Status) |
| | 131 | | { |
| | 132 | | case 200: |
| | 133 | | case 202: |
| 4 | 134 | | return message.Response; |
| | 135 | | default: |
| 0 | 136 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 137 | | } |
| 4 | 138 | | } |
| | 139 | |
|
| | 140 | | internal HttpMessage CreateReimageAllRequest(string resourceGroupName, string vmScaleSetName, string instanceId) |
| | 141 | | { |
| 8 | 142 | | var message = _pipeline.CreateMessage(); |
| 8 | 143 | | var request = message.Request; |
| 8 | 144 | | request.Method = RequestMethod.Post; |
| 8 | 145 | | var uri = new RawRequestUriBuilder(); |
| 8 | 146 | | uri.Reset(endpoint); |
| 8 | 147 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 148 | | uri.AppendPath(subscriptionId, true); |
| 8 | 149 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 150 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 151 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 8 | 152 | | uri.AppendPath(vmScaleSetName, true); |
| 8 | 153 | | uri.AppendPath("/virtualmachines/", false); |
| 8 | 154 | | uri.AppendPath(instanceId, true); |
| 8 | 155 | | uri.AppendPath("/reimageall", false); |
| 8 | 156 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 157 | | request.Uri = uri; |
| 8 | 158 | | return message; |
| | 159 | | } |
| | 160 | |
|
| | 161 | | /// <summary> Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This |
| | 162 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 163 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 164 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 165 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 166 | | public async Task<Response> ReimageAllAsync(string resourceGroupName, string vmScaleSetName, string instanceId, |
| | 167 | | { |
| 2 | 168 | | if (resourceGroupName == null) |
| | 169 | | { |
| 0 | 170 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 171 | | } |
| 2 | 172 | | if (vmScaleSetName == null) |
| | 173 | | { |
| 0 | 174 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 175 | | } |
| 2 | 176 | | if (instanceId == null) |
| | 177 | | { |
| 0 | 178 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 179 | | } |
| | 180 | |
|
| 2 | 181 | | using var message = CreateReimageAllRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 2 | 182 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 183 | | switch (message.Response.Status) |
| | 184 | | { |
| | 185 | | case 200: |
| | 186 | | case 202: |
| 2 | 187 | | return message.Response; |
| | 188 | | default: |
| 0 | 189 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 190 | | } |
| 2 | 191 | | } |
| | 192 | |
|
| | 193 | | /// <summary> Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This |
| | 194 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 195 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 196 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 197 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 198 | | public Response ReimageAll(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken |
| | 199 | | { |
| 2 | 200 | | if (resourceGroupName == null) |
| | 201 | | { |
| 0 | 202 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 203 | | } |
| 2 | 204 | | if (vmScaleSetName == null) |
| | 205 | | { |
| 0 | 206 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 207 | | } |
| 2 | 208 | | if (instanceId == null) |
| | 209 | | { |
| 0 | 210 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 211 | | } |
| | 212 | |
|
| 2 | 213 | | using var message = CreateReimageAllRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 2 | 214 | | _pipeline.Send(message, cancellationToken); |
| 2 | 215 | | switch (message.Response.Status) |
| | 216 | | { |
| | 217 | | case 200: |
| | 218 | | case 202: |
| 2 | 219 | | return message.Response; |
| | 220 | | default: |
| 0 | 221 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 222 | | } |
| 2 | 223 | | } |
| | 224 | |
|
| | 225 | | internal HttpMessage CreateDeallocateRequest(string resourceGroupName, string vmScaleSetName, string instanceId) |
| | 226 | | { |
| 16 | 227 | | var message = _pipeline.CreateMessage(); |
| 16 | 228 | | var request = message.Request; |
| 16 | 229 | | request.Method = RequestMethod.Post; |
| 16 | 230 | | var uri = new RawRequestUriBuilder(); |
| 16 | 231 | | uri.Reset(endpoint); |
| 16 | 232 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 233 | | uri.AppendPath(subscriptionId, true); |
| 16 | 234 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 235 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 236 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 237 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 238 | | uri.AppendPath("/virtualmachines/", false); |
| 16 | 239 | | uri.AppendPath(instanceId, true); |
| 16 | 240 | | uri.AppendPath("/deallocate", false); |
| 16 | 241 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 242 | | request.Uri = uri; |
| 16 | 243 | | return message; |
| | 244 | | } |
| | 245 | |
|
| | 246 | | /// <summary> Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and relea |
| | 247 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 248 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 249 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 250 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 251 | | public async Task<Response> DeallocateAsync(string resourceGroupName, string vmScaleSetName, string instanceId, |
| | 252 | | { |
| 4 | 253 | | if (resourceGroupName == null) |
| | 254 | | { |
| 0 | 255 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 256 | | } |
| 4 | 257 | | if (vmScaleSetName == null) |
| | 258 | | { |
| 0 | 259 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 260 | | } |
| 4 | 261 | | if (instanceId == null) |
| | 262 | | { |
| 0 | 263 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 264 | | } |
| | 265 | |
|
| 4 | 266 | | using var message = CreateDeallocateRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 267 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 268 | | switch (message.Response.Status) |
| | 269 | | { |
| | 270 | | case 200: |
| | 271 | | case 202: |
| 4 | 272 | | return message.Response; |
| | 273 | | default: |
| 0 | 274 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 275 | | } |
| 4 | 276 | | } |
| | 277 | |
|
| | 278 | | /// <summary> Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and relea |
| | 279 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 280 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 281 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 282 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 283 | | public Response Deallocate(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken |
| | 284 | | { |
| 4 | 285 | | if (resourceGroupName == null) |
| | 286 | | { |
| 0 | 287 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 288 | | } |
| 4 | 289 | | if (vmScaleSetName == null) |
| | 290 | | { |
| 0 | 291 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 292 | | } |
| 4 | 293 | | if (instanceId == null) |
| | 294 | | { |
| 0 | 295 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 296 | | } |
| | 297 | |
|
| 4 | 298 | | using var message = CreateDeallocateRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 299 | | _pipeline.Send(message, cancellationToken); |
| 4 | 300 | | switch (message.Response.Status) |
| | 301 | | { |
| | 302 | | case 200: |
| | 303 | | case 202: |
| 4 | 304 | | return message.Response; |
| | 305 | | default: |
| 0 | 306 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 307 | | } |
| 4 | 308 | | } |
| | 309 | |
|
| | 310 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string vmScaleSetName, string instanceId, Vir |
| | 311 | | { |
| 0 | 312 | | var message = _pipeline.CreateMessage(); |
| 0 | 313 | | var request = message.Request; |
| 0 | 314 | | request.Method = RequestMethod.Put; |
| 0 | 315 | | var uri = new RawRequestUriBuilder(); |
| 0 | 316 | | uri.Reset(endpoint); |
| 0 | 317 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 318 | | uri.AppendPath(subscriptionId, true); |
| 0 | 319 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 320 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 321 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 322 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 323 | | uri.AppendPath("/virtualmachines/", false); |
| 0 | 324 | | uri.AppendPath(instanceId, true); |
| 0 | 325 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 326 | | request.Uri = uri; |
| 0 | 327 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 328 | | var content = new Utf8JsonRequestContent(); |
| 0 | 329 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 330 | | request.Content = content; |
| 0 | 331 | | return message; |
| | 332 | | } |
| | 333 | |
|
| | 334 | | /// <summary> Updates a virtual machine of a VM scale set. </summary> |
| | 335 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 336 | | /// <param name="vmScaleSetName"> The name of the VM scale set where the extension should be create or updated. |
| | 337 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 338 | | /// <param name="parameters"> Parameters supplied to the Update Virtual Machine Scale Sets VM operation. </param |
| | 339 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 340 | | public async Task<Response> UpdateAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Virt |
| | 341 | | { |
| 0 | 342 | | if (resourceGroupName == null) |
| | 343 | | { |
| 0 | 344 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 345 | | } |
| 0 | 346 | | if (vmScaleSetName == null) |
| | 347 | | { |
| 0 | 348 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 349 | | } |
| 0 | 350 | | if (instanceId == null) |
| | 351 | | { |
| 0 | 352 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 353 | | } |
| 0 | 354 | | if (parameters == null) |
| | 355 | | { |
| 0 | 356 | | throw new ArgumentNullException(nameof(parameters)); |
| | 357 | | } |
| | 358 | |
|
| 0 | 359 | | using var message = CreateUpdateRequest(resourceGroupName, vmScaleSetName, instanceId, parameters); |
| 0 | 360 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 361 | | switch (message.Response.Status) |
| | 362 | | { |
| | 363 | | case 200: |
| | 364 | | case 202: |
| 0 | 365 | | return message.Response; |
| | 366 | | default: |
| 0 | 367 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 368 | | } |
| 0 | 369 | | } |
| | 370 | |
|
| | 371 | | /// <summary> Updates a virtual machine of a VM scale set. </summary> |
| | 372 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 373 | | /// <param name="vmScaleSetName"> The name of the VM scale set where the extension should be create or updated. |
| | 374 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 375 | | /// <param name="parameters"> Parameters supplied to the Update Virtual Machine Scale Sets VM operation. </param |
| | 376 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 377 | | public Response Update(string resourceGroupName, string vmScaleSetName, string instanceId, VirtualMachineScaleSe |
| | 378 | | { |
| 0 | 379 | | if (resourceGroupName == null) |
| | 380 | | { |
| 0 | 381 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 382 | | } |
| 0 | 383 | | if (vmScaleSetName == null) |
| | 384 | | { |
| 0 | 385 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 386 | | } |
| 0 | 387 | | if (instanceId == null) |
| | 388 | | { |
| 0 | 389 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 390 | | } |
| 0 | 391 | | if (parameters == null) |
| | 392 | | { |
| 0 | 393 | | throw new ArgumentNullException(nameof(parameters)); |
| | 394 | | } |
| | 395 | |
|
| 0 | 396 | | using var message = CreateUpdateRequest(resourceGroupName, vmScaleSetName, instanceId, parameters); |
| 0 | 397 | | _pipeline.Send(message, cancellationToken); |
| 0 | 398 | | switch (message.Response.Status) |
| | 399 | | { |
| | 400 | | case 200: |
| | 401 | | case 202: |
| 0 | 402 | | return message.Response; |
| | 403 | | default: |
| 0 | 404 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 405 | | } |
| 0 | 406 | | } |
| | 407 | |
|
| | 408 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string vmScaleSetName, string instanceId) |
| | 409 | | { |
| 16 | 410 | | var message = _pipeline.CreateMessage(); |
| 16 | 411 | | var request = message.Request; |
| 16 | 412 | | request.Method = RequestMethod.Delete; |
| 16 | 413 | | var uri = new RawRequestUriBuilder(); |
| 16 | 414 | | uri.Reset(endpoint); |
| 16 | 415 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 416 | | uri.AppendPath(subscriptionId, true); |
| 16 | 417 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 418 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 419 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 420 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 421 | | uri.AppendPath("/virtualmachines/", false); |
| 16 | 422 | | uri.AppendPath(instanceId, true); |
| 16 | 423 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 424 | | request.Uri = uri; |
| 16 | 425 | | return message; |
| | 426 | | } |
| | 427 | |
|
| | 428 | | /// <summary> Deletes a virtual machine from a VM scale set. </summary> |
| | 429 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 430 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 431 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 432 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 433 | | public async Task<Response> DeleteAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Canc |
| | 434 | | { |
| 4 | 435 | | if (resourceGroupName == null) |
| | 436 | | { |
| 0 | 437 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 438 | | } |
| 4 | 439 | | if (vmScaleSetName == null) |
| | 440 | | { |
| 0 | 441 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 442 | | } |
| 4 | 443 | | if (instanceId == null) |
| | 444 | | { |
| 0 | 445 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 446 | | } |
| | 447 | |
|
| 4 | 448 | | using var message = CreateDeleteRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 449 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 450 | | switch (message.Response.Status) |
| | 451 | | { |
| | 452 | | case 200: |
| | 453 | | case 202: |
| | 454 | | case 204: |
| 4 | 455 | | return message.Response; |
| | 456 | | default: |
| 0 | 457 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 458 | | } |
| 4 | 459 | | } |
| | 460 | |
|
| | 461 | | /// <summary> Deletes a virtual machine from a VM scale set. </summary> |
| | 462 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 463 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 464 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 465 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 466 | | public Response Delete(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken can |
| | 467 | | { |
| 4 | 468 | | if (resourceGroupName == null) |
| | 469 | | { |
| 0 | 470 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 471 | | } |
| 4 | 472 | | if (vmScaleSetName == null) |
| | 473 | | { |
| 0 | 474 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 475 | | } |
| 4 | 476 | | if (instanceId == null) |
| | 477 | | { |
| 0 | 478 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 479 | | } |
| | 480 | |
|
| 4 | 481 | | using var message = CreateDeleteRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 482 | | _pipeline.Send(message, cancellationToken); |
| 4 | 483 | | switch (message.Response.Status) |
| | 484 | | { |
| | 485 | | case 200: |
| | 486 | | case 202: |
| | 487 | | case 204: |
| 4 | 488 | | return message.Response; |
| | 489 | | default: |
| 0 | 490 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 491 | | } |
| 4 | 492 | | } |
| | 493 | |
|
| | 494 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string vmScaleSetName, string instanceId) |
| | 495 | | { |
| 32 | 496 | | var message = _pipeline.CreateMessage(); |
| 32 | 497 | | var request = message.Request; |
| 32 | 498 | | request.Method = RequestMethod.Get; |
| 32 | 499 | | var uri = new RawRequestUriBuilder(); |
| 32 | 500 | | uri.Reset(endpoint); |
| 32 | 501 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 502 | | uri.AppendPath(subscriptionId, true); |
| 32 | 503 | | uri.AppendPath("/resourceGroups/", false); |
| 32 | 504 | | uri.AppendPath(resourceGroupName, true); |
| 32 | 505 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 32 | 506 | | uri.AppendPath(vmScaleSetName, true); |
| 32 | 507 | | uri.AppendPath("/virtualmachines/", false); |
| 32 | 508 | | uri.AppendPath(instanceId, true); |
| 32 | 509 | | uri.AppendQuery("$expand", "instanceView", true); |
| 32 | 510 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 32 | 511 | | request.Uri = uri; |
| 32 | 512 | | return message; |
| | 513 | | } |
| | 514 | |
|
| | 515 | | /// <summary> Gets a virtual machine from a VM scale set. </summary> |
| | 516 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 517 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 518 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 519 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 520 | | public async Task<Response<VirtualMachineScaleSetVM>> GetAsync(string resourceGroupName, string vmScaleSetName, |
| | 521 | | { |
| 16 | 522 | | if (resourceGroupName == null) |
| | 523 | | { |
| 0 | 524 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 525 | | } |
| 16 | 526 | | if (vmScaleSetName == null) |
| | 527 | | { |
| 0 | 528 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 529 | | } |
| 16 | 530 | | if (instanceId == null) |
| | 531 | | { |
| 0 | 532 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 533 | | } |
| | 534 | |
|
| 16 | 535 | | using var message = CreateGetRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 16 | 536 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 537 | | switch (message.Response.Status) |
| | 538 | | { |
| | 539 | | case 200: |
| | 540 | | { |
| 16 | 541 | | VirtualMachineScaleSetVM value = default; |
| 16 | 542 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 16 | 543 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 544 | | { |
| 0 | 545 | | value = null; |
| | 546 | | } |
| | 547 | | else |
| | 548 | | { |
| 16 | 549 | | value = VirtualMachineScaleSetVM.DeserializeVirtualMachineScaleSetVM(document.RootElement); |
| | 550 | | } |
| 16 | 551 | | return Response.FromValue(value, message.Response); |
| | 552 | | } |
| | 553 | | default: |
| 0 | 554 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 555 | | } |
| 16 | 556 | | } |
| | 557 | |
|
| | 558 | | /// <summary> Gets a virtual machine from a VM scale set. </summary> |
| | 559 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 560 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 561 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 562 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 563 | | public Response<VirtualMachineScaleSetVM> Get(string resourceGroupName, string vmScaleSetName, string instanceId |
| | 564 | | { |
| 16 | 565 | | if (resourceGroupName == null) |
| | 566 | | { |
| 0 | 567 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 568 | | } |
| 16 | 569 | | if (vmScaleSetName == null) |
| | 570 | | { |
| 0 | 571 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 572 | | } |
| 16 | 573 | | if (instanceId == null) |
| | 574 | | { |
| 0 | 575 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 576 | | } |
| | 577 | |
|
| 16 | 578 | | using var message = CreateGetRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 16 | 579 | | _pipeline.Send(message, cancellationToken); |
| 16 | 580 | | switch (message.Response.Status) |
| | 581 | | { |
| | 582 | | case 200: |
| | 583 | | { |
| 16 | 584 | | VirtualMachineScaleSetVM value = default; |
| 16 | 585 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 16 | 586 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 587 | | { |
| 0 | 588 | | value = null; |
| | 589 | | } |
| | 590 | | else |
| | 591 | | { |
| 16 | 592 | | value = VirtualMachineScaleSetVM.DeserializeVirtualMachineScaleSetVM(document.RootElement); |
| | 593 | | } |
| 16 | 594 | | return Response.FromValue(value, message.Response); |
| | 595 | | } |
| | 596 | | default: |
| 0 | 597 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 598 | | } |
| 16 | 599 | | } |
| | 600 | |
|
| | 601 | | internal HttpMessage CreateGetInstanceViewRequest(string resourceGroupName, string vmScaleSetName, string instan |
| | 602 | | { |
| 8 | 603 | | var message = _pipeline.CreateMessage(); |
| 8 | 604 | | var request = message.Request; |
| 8 | 605 | | request.Method = RequestMethod.Get; |
| 8 | 606 | | var uri = new RawRequestUriBuilder(); |
| 8 | 607 | | uri.Reset(endpoint); |
| 8 | 608 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 609 | | uri.AppendPath(subscriptionId, true); |
| 8 | 610 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 611 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 612 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 8 | 613 | | uri.AppendPath(vmScaleSetName, true); |
| 8 | 614 | | uri.AppendPath("/virtualmachines/", false); |
| 8 | 615 | | uri.AppendPath(instanceId, true); |
| 8 | 616 | | uri.AppendPath("/instanceView", false); |
| 8 | 617 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 618 | | request.Uri = uri; |
| 8 | 619 | | return message; |
| | 620 | | } |
| | 621 | |
|
| | 622 | | /// <summary> Gets the status of a virtual machine from a VM scale set. </summary> |
| | 623 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 624 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 625 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 626 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 627 | | public async Task<Response<VirtualMachineScaleSetVMInstanceView>> GetInstanceViewAsync(string resourceGroupName, |
| | 628 | | { |
| 4 | 629 | | if (resourceGroupName == null) |
| | 630 | | { |
| 0 | 631 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 632 | | } |
| 4 | 633 | | if (vmScaleSetName == null) |
| | 634 | | { |
| 0 | 635 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 636 | | } |
| 4 | 637 | | if (instanceId == null) |
| | 638 | | { |
| 0 | 639 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 640 | | } |
| | 641 | |
|
| 4 | 642 | | using var message = CreateGetInstanceViewRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 643 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 644 | | switch (message.Response.Status) |
| | 645 | | { |
| | 646 | | case 200: |
| | 647 | | { |
| 4 | 648 | | VirtualMachineScaleSetVMInstanceView value = default; |
| 4 | 649 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 650 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 651 | | { |
| 0 | 652 | | value = null; |
| | 653 | | } |
| | 654 | | else |
| | 655 | | { |
| 4 | 656 | | value = VirtualMachineScaleSetVMInstanceView.DeserializeVirtualMachineScaleSetVMInstanceView |
| | 657 | | } |
| 4 | 658 | | return Response.FromValue(value, message.Response); |
| | 659 | | } |
| | 660 | | default: |
| 0 | 661 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 662 | | } |
| 4 | 663 | | } |
| | 664 | |
|
| | 665 | | /// <summary> Gets the status of a virtual machine from a VM scale set. </summary> |
| | 666 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 667 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 668 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 669 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 670 | | public Response<VirtualMachineScaleSetVMInstanceView> GetInstanceView(string resourceGroupName, string vmScaleSe |
| | 671 | | { |
| 4 | 672 | | if (resourceGroupName == null) |
| | 673 | | { |
| 0 | 674 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 675 | | } |
| 4 | 676 | | if (vmScaleSetName == null) |
| | 677 | | { |
| 0 | 678 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 679 | | } |
| 4 | 680 | | if (instanceId == null) |
| | 681 | | { |
| 0 | 682 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 683 | | } |
| | 684 | |
|
| 4 | 685 | | using var message = CreateGetInstanceViewRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 686 | | _pipeline.Send(message, cancellationToken); |
| 4 | 687 | | switch (message.Response.Status) |
| | 688 | | { |
| | 689 | | case 200: |
| | 690 | | { |
| 4 | 691 | | VirtualMachineScaleSetVMInstanceView value = default; |
| 4 | 692 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 693 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 694 | | { |
| 0 | 695 | | value = null; |
| | 696 | | } |
| | 697 | | else |
| | 698 | | { |
| 4 | 699 | | value = VirtualMachineScaleSetVMInstanceView.DeserializeVirtualMachineScaleSetVMInstanceView |
| | 700 | | } |
| 4 | 701 | | return Response.FromValue(value, message.Response); |
| | 702 | | } |
| | 703 | | default: |
| 0 | 704 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 705 | | } |
| 4 | 706 | | } |
| | 707 | |
|
| | 708 | | internal HttpMessage CreateListRequest(string resourceGroupName, string virtualMachineScaleSetName, string filte |
| | 709 | | { |
| 28 | 710 | | var message = _pipeline.CreateMessage(); |
| 28 | 711 | | var request = message.Request; |
| 28 | 712 | | request.Method = RequestMethod.Get; |
| 28 | 713 | | var uri = new RawRequestUriBuilder(); |
| 28 | 714 | | uri.Reset(endpoint); |
| 28 | 715 | | uri.AppendPath("/subscriptions/", false); |
| 28 | 716 | | uri.AppendPath(subscriptionId, true); |
| 28 | 717 | | uri.AppendPath("/resourceGroups/", false); |
| 28 | 718 | | uri.AppendPath(resourceGroupName, true); |
| 28 | 719 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 28 | 720 | | uri.AppendPath(virtualMachineScaleSetName, true); |
| 28 | 721 | | uri.AppendPath("/virtualMachines", false); |
| 28 | 722 | | if (filter != null) |
| | 723 | | { |
| 20 | 724 | | uri.AppendQuery("$filter", filter, true); |
| | 725 | | } |
| 28 | 726 | | if (select != null) |
| | 727 | | { |
| 0 | 728 | | uri.AppendQuery("$select", select, true); |
| | 729 | | } |
| 28 | 730 | | if (expand != null) |
| | 731 | | { |
| 8 | 732 | | uri.AppendQuery("$expand", expand, true); |
| | 733 | | } |
| 28 | 734 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 28 | 735 | | request.Uri = uri; |
| 28 | 736 | | return message; |
| | 737 | | } |
| | 738 | |
|
| | 739 | | /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary> |
| | 740 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 741 | | /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param> |
| | 742 | | /// <param name="filter"> The filter to apply to the operation. </param> |
| | 743 | | /// <param name="select"> The list parameters. </param> |
| | 744 | | /// <param name="expand"> The expand expression to apply to the operation. </param> |
| | 745 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 746 | | public async Task<Response<VirtualMachineScaleSetVMListResult>> ListAsync(string resourceGroupName, string virtu |
| | 747 | | { |
| 14 | 748 | | if (resourceGroupName == null) |
| | 749 | | { |
| 0 | 750 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 751 | | } |
| 14 | 752 | | if (virtualMachineScaleSetName == null) |
| | 753 | | { |
| 0 | 754 | | throw new ArgumentNullException(nameof(virtualMachineScaleSetName)); |
| | 755 | | } |
| | 756 | |
|
| 14 | 757 | | using var message = CreateListRequest(resourceGroupName, virtualMachineScaleSetName, filter, select, expand) |
| 14 | 758 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 14 | 759 | | switch (message.Response.Status) |
| | 760 | | { |
| | 761 | | case 200: |
| | 762 | | { |
| 14 | 763 | | VirtualMachineScaleSetVMListResult value = default; |
| 14 | 764 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 14 | 765 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 766 | | { |
| 0 | 767 | | value = null; |
| | 768 | | } |
| | 769 | | else |
| | 770 | | { |
| 14 | 771 | | value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc |
| | 772 | | } |
| 14 | 773 | | return Response.FromValue(value, message.Response); |
| | 774 | | } |
| | 775 | | default: |
| 0 | 776 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 777 | | } |
| 14 | 778 | | } |
| | 779 | |
|
| | 780 | | /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary> |
| | 781 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 782 | | /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param> |
| | 783 | | /// <param name="filter"> The filter to apply to the operation. </param> |
| | 784 | | /// <param name="select"> The list parameters. </param> |
| | 785 | | /// <param name="expand"> The expand expression to apply to the operation. </param> |
| | 786 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 787 | | public Response<VirtualMachineScaleSetVMListResult> List(string resourceGroupName, string virtualMachineScaleSet |
| | 788 | | { |
| 14 | 789 | | if (resourceGroupName == null) |
| | 790 | | { |
| 0 | 791 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 792 | | } |
| 14 | 793 | | if (virtualMachineScaleSetName == null) |
| | 794 | | { |
| 0 | 795 | | throw new ArgumentNullException(nameof(virtualMachineScaleSetName)); |
| | 796 | | } |
| | 797 | |
|
| 14 | 798 | | using var message = CreateListRequest(resourceGroupName, virtualMachineScaleSetName, filter, select, expand) |
| 14 | 799 | | _pipeline.Send(message, cancellationToken); |
| 14 | 800 | | switch (message.Response.Status) |
| | 801 | | { |
| | 802 | | case 200: |
| | 803 | | { |
| 14 | 804 | | VirtualMachineScaleSetVMListResult value = default; |
| 14 | 805 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 14 | 806 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 807 | | { |
| 0 | 808 | | value = null; |
| | 809 | | } |
| | 810 | | else |
| | 811 | | { |
| 14 | 812 | | value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc |
| | 813 | | } |
| 14 | 814 | | return Response.FromValue(value, message.Response); |
| | 815 | | } |
| | 816 | | default: |
| 0 | 817 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 818 | | } |
| 14 | 819 | | } |
| | 820 | |
|
| | 821 | | internal HttpMessage CreatePowerOffRequest(string resourceGroupName, string vmScaleSetName, string instanceId, b |
| | 822 | | { |
| 16 | 823 | | var message = _pipeline.CreateMessage(); |
| 16 | 824 | | var request = message.Request; |
| 16 | 825 | | request.Method = RequestMethod.Post; |
| 16 | 826 | | var uri = new RawRequestUriBuilder(); |
| 16 | 827 | | uri.Reset(endpoint); |
| 16 | 828 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 829 | | uri.AppendPath(subscriptionId, true); |
| 16 | 830 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 831 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 832 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 833 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 834 | | uri.AppendPath("/virtualmachines/", false); |
| 16 | 835 | | uri.AppendPath(instanceId, true); |
| 16 | 836 | | uri.AppendPath("/poweroff", false); |
| 16 | 837 | | if (skipShutdown != null) |
| | 838 | | { |
| 0 | 839 | | uri.AppendQuery("skipShutdown", skipShutdown.Value, true); |
| | 840 | | } |
| 16 | 841 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 842 | | request.Uri = uri; |
| 16 | 843 | | return message; |
| | 844 | | } |
| | 845 | |
|
| | 846 | | /// <summary> Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and y |
| | 847 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 848 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 849 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 850 | | /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi |
| | 851 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 852 | | public async Task<Response> PowerOffAsync(string resourceGroupName, string vmScaleSetName, string instanceId, bo |
| | 853 | | { |
| 4 | 854 | | if (resourceGroupName == null) |
| | 855 | | { |
| 0 | 856 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 857 | | } |
| 4 | 858 | | if (vmScaleSetName == null) |
| | 859 | | { |
| 0 | 860 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 861 | | } |
| 4 | 862 | | if (instanceId == null) |
| | 863 | | { |
| 0 | 864 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 865 | | } |
| | 866 | |
|
| 4 | 867 | | using var message = CreatePowerOffRequest(resourceGroupName, vmScaleSetName, instanceId, skipShutdown); |
| 4 | 868 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 869 | | switch (message.Response.Status) |
| | 870 | | { |
| | 871 | | case 200: |
| | 872 | | case 202: |
| 4 | 873 | | return message.Response; |
| | 874 | | default: |
| 0 | 875 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 876 | | } |
| 4 | 877 | | } |
| | 878 | |
|
| | 879 | | /// <summary> Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and y |
| | 880 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 881 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 882 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 883 | | /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi |
| | 884 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 885 | | public Response PowerOff(string resourceGroupName, string vmScaleSetName, string instanceId, bool? skipShutdown |
| | 886 | | { |
| 4 | 887 | | if (resourceGroupName == null) |
| | 888 | | { |
| 0 | 889 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 890 | | } |
| 4 | 891 | | if (vmScaleSetName == null) |
| | 892 | | { |
| 0 | 893 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 894 | | } |
| 4 | 895 | | if (instanceId == null) |
| | 896 | | { |
| 0 | 897 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 898 | | } |
| | 899 | |
|
| 4 | 900 | | using var message = CreatePowerOffRequest(resourceGroupName, vmScaleSetName, instanceId, skipShutdown); |
| 4 | 901 | | _pipeline.Send(message, cancellationToken); |
| 4 | 902 | | switch (message.Response.Status) |
| | 903 | | { |
| | 904 | | case 200: |
| | 905 | | case 202: |
| 4 | 906 | | return message.Response; |
| | 907 | | default: |
| 0 | 908 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 909 | | } |
| 4 | 910 | | } |
| | 911 | |
|
| | 912 | | internal HttpMessage CreateRestartRequest(string resourceGroupName, string vmScaleSetName, string instanceId) |
| | 913 | | { |
| 16 | 914 | | var message = _pipeline.CreateMessage(); |
| 16 | 915 | | var request = message.Request; |
| 16 | 916 | | request.Method = RequestMethod.Post; |
| 16 | 917 | | var uri = new RawRequestUriBuilder(); |
| 16 | 918 | | uri.Reset(endpoint); |
| 16 | 919 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 920 | | uri.AppendPath(subscriptionId, true); |
| 16 | 921 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 922 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 923 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 924 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 925 | | uri.AppendPath("/virtualmachines/", false); |
| 16 | 926 | | uri.AppendPath(instanceId, true); |
| 16 | 927 | | uri.AppendPath("/restart", false); |
| 16 | 928 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 929 | | request.Uri = uri; |
| 16 | 930 | | return message; |
| | 931 | | } |
| | 932 | |
|
| | 933 | | /// <summary> Restarts a virtual machine in a VM scale set. </summary> |
| | 934 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 935 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 936 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 937 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 938 | | public async Task<Response> RestartAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Can |
| | 939 | | { |
| 4 | 940 | | if (resourceGroupName == null) |
| | 941 | | { |
| 0 | 942 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 943 | | } |
| 4 | 944 | | if (vmScaleSetName == null) |
| | 945 | | { |
| 0 | 946 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 947 | | } |
| 4 | 948 | | if (instanceId == null) |
| | 949 | | { |
| 0 | 950 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 951 | | } |
| | 952 | |
|
| 4 | 953 | | using var message = CreateRestartRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 954 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 955 | | switch (message.Response.Status) |
| | 956 | | { |
| | 957 | | case 200: |
| | 958 | | case 202: |
| 4 | 959 | | return message.Response; |
| | 960 | | default: |
| 0 | 961 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 962 | | } |
| 4 | 963 | | } |
| | 964 | |
|
| | 965 | | /// <summary> Restarts a virtual machine in a VM scale set. </summary> |
| | 966 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 967 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 968 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 969 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 970 | | public Response Restart(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken ca |
| | 971 | | { |
| 4 | 972 | | if (resourceGroupName == null) |
| | 973 | | { |
| 0 | 974 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 975 | | } |
| 4 | 976 | | if (vmScaleSetName == null) |
| | 977 | | { |
| 0 | 978 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 979 | | } |
| 4 | 980 | | if (instanceId == null) |
| | 981 | | { |
| 0 | 982 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 983 | | } |
| | 984 | |
|
| 4 | 985 | | using var message = CreateRestartRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 4 | 986 | | _pipeline.Send(message, cancellationToken); |
| 4 | 987 | | switch (message.Response.Status) |
| | 988 | | { |
| | 989 | | case 200: |
| | 990 | | case 202: |
| 4 | 991 | | return message.Response; |
| | 992 | | default: |
| 0 | 993 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 994 | | } |
| 4 | 995 | | } |
| | 996 | |
|
| | 997 | | internal HttpMessage CreateStartRequest(string resourceGroupName, string vmScaleSetName, string instanceId) |
| | 998 | | { |
| 24 | 999 | | var message = _pipeline.CreateMessage(); |
| 24 | 1000 | | var request = message.Request; |
| 24 | 1001 | | request.Method = RequestMethod.Post; |
| 24 | 1002 | | var uri = new RawRequestUriBuilder(); |
| 24 | 1003 | | uri.Reset(endpoint); |
| 24 | 1004 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 1005 | | uri.AppendPath(subscriptionId, true); |
| 24 | 1006 | | uri.AppendPath("/resourceGroups/", false); |
| 24 | 1007 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 1008 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 24 | 1009 | | uri.AppendPath(vmScaleSetName, true); |
| 24 | 1010 | | uri.AppendPath("/virtualmachines/", false); |
| 24 | 1011 | | uri.AppendPath(instanceId, true); |
| 24 | 1012 | | uri.AppendPath("/start", false); |
| 24 | 1013 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 24 | 1014 | | request.Uri = uri; |
| 24 | 1015 | | return message; |
| | 1016 | | } |
| | 1017 | |
|
| | 1018 | | /// <summary> Starts a virtual machine in a VM scale set. </summary> |
| | 1019 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1020 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1021 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1022 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1023 | | public async Task<Response> StartAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Cance |
| | 1024 | | { |
| 6 | 1025 | | if (resourceGroupName == null) |
| | 1026 | | { |
| 0 | 1027 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1028 | | } |
| 6 | 1029 | | if (vmScaleSetName == null) |
| | 1030 | | { |
| 0 | 1031 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1032 | | } |
| 6 | 1033 | | if (instanceId == null) |
| | 1034 | | { |
| 0 | 1035 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1036 | | } |
| | 1037 | |
|
| 6 | 1038 | | using var message = CreateStartRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 6 | 1039 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 1040 | | switch (message.Response.Status) |
| | 1041 | | { |
| | 1042 | | case 200: |
| | 1043 | | case 202: |
| 6 | 1044 | | return message.Response; |
| | 1045 | | default: |
| 0 | 1046 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1047 | | } |
| 6 | 1048 | | } |
| | 1049 | |
|
| | 1050 | | /// <summary> Starts a virtual machine in a VM scale set. </summary> |
| | 1051 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1052 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1053 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1054 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1055 | | public Response Start(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken canc |
| | 1056 | | { |
| 6 | 1057 | | if (resourceGroupName == null) |
| | 1058 | | { |
| 0 | 1059 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1060 | | } |
| 6 | 1061 | | if (vmScaleSetName == null) |
| | 1062 | | { |
| 0 | 1063 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1064 | | } |
| 6 | 1065 | | if (instanceId == null) |
| | 1066 | | { |
| 0 | 1067 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1068 | | } |
| | 1069 | |
|
| 6 | 1070 | | using var message = CreateStartRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 6 | 1071 | | _pipeline.Send(message, cancellationToken); |
| 6 | 1072 | | switch (message.Response.Status) |
| | 1073 | | { |
| | 1074 | | case 200: |
| | 1075 | | case 202: |
| 6 | 1076 | | return message.Response; |
| | 1077 | | default: |
| 0 | 1078 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1079 | | } |
| 6 | 1080 | | } |
| | 1081 | |
|
| | 1082 | | internal HttpMessage CreateRedeployRequest(string resourceGroupName, string vmScaleSetName, string instanceId) |
| | 1083 | | { |
| 8 | 1084 | | var message = _pipeline.CreateMessage(); |
| 8 | 1085 | | var request = message.Request; |
| 8 | 1086 | | request.Method = RequestMethod.Post; |
| 8 | 1087 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1088 | | uri.Reset(endpoint); |
| 8 | 1089 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 1090 | | uri.AppendPath(subscriptionId, true); |
| 8 | 1091 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 1092 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 1093 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 8 | 1094 | | uri.AppendPath(vmScaleSetName, true); |
| 8 | 1095 | | uri.AppendPath("/virtualmachines/", false); |
| 8 | 1096 | | uri.AppendPath(instanceId, true); |
| 8 | 1097 | | uri.AppendPath("/redeploy", false); |
| 8 | 1098 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 1099 | | request.Uri = uri; |
| 8 | 1100 | | return message; |
| | 1101 | | } |
| | 1102 | |
|
| | 1103 | | /// <summary> Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and power |
| | 1104 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1105 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1106 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1107 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1108 | | public async Task<Response> RedeployAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Ca |
| | 1109 | | { |
| 2 | 1110 | | if (resourceGroupName == null) |
| | 1111 | | { |
| 0 | 1112 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1113 | | } |
| 2 | 1114 | | if (vmScaleSetName == null) |
| | 1115 | | { |
| 0 | 1116 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1117 | | } |
| 2 | 1118 | | if (instanceId == null) |
| | 1119 | | { |
| 0 | 1120 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1121 | | } |
| | 1122 | |
|
| 2 | 1123 | | using var message = CreateRedeployRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 2 | 1124 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1125 | | switch (message.Response.Status) |
| | 1126 | | { |
| | 1127 | | case 200: |
| | 1128 | | case 202: |
| 2 | 1129 | | return message.Response; |
| | 1130 | | default: |
| 0 | 1131 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1132 | | } |
| 2 | 1133 | | } |
| | 1134 | |
|
| | 1135 | | /// <summary> Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and power |
| | 1136 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1137 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1138 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1139 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1140 | | public Response Redeploy(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken c |
| | 1141 | | { |
| 2 | 1142 | | if (resourceGroupName == null) |
| | 1143 | | { |
| 0 | 1144 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1145 | | } |
| 2 | 1146 | | if (vmScaleSetName == null) |
| | 1147 | | { |
| 0 | 1148 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1149 | | } |
| 2 | 1150 | | if (instanceId == null) |
| | 1151 | | { |
| 0 | 1152 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1153 | | } |
| | 1154 | |
|
| 2 | 1155 | | using var message = CreateRedeployRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 2 | 1156 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1157 | | switch (message.Response.Status) |
| | 1158 | | { |
| | 1159 | | case 200: |
| | 1160 | | case 202: |
| 2 | 1161 | | return message.Response; |
| | 1162 | | default: |
| 0 | 1163 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1164 | | } |
| 2 | 1165 | | } |
| | 1166 | |
|
| | 1167 | | internal HttpMessage CreatePerformMaintenanceRequest(string resourceGroupName, string vmScaleSetName, string ins |
| | 1168 | | { |
| 4 | 1169 | | var message = _pipeline.CreateMessage(); |
| 4 | 1170 | | var request = message.Request; |
| 4 | 1171 | | request.Method = RequestMethod.Post; |
| 4 | 1172 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1173 | | uri.Reset(endpoint); |
| 4 | 1174 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 1175 | | uri.AppendPath(subscriptionId, true); |
| 4 | 1176 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 1177 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 1178 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 4 | 1179 | | uri.AppendPath(vmScaleSetName, true); |
| 4 | 1180 | | uri.AppendPath("/virtualmachines/", false); |
| 4 | 1181 | | uri.AppendPath(instanceId, true); |
| 4 | 1182 | | uri.AppendPath("/performMaintenance", false); |
| 4 | 1183 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 4 | 1184 | | request.Uri = uri; |
| 4 | 1185 | | return message; |
| | 1186 | | } |
| | 1187 | |
|
| | 1188 | | /// <summary> Performs maintenance on a virtual machine in a VM scale set. </summary> |
| | 1189 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1190 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1191 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1192 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1193 | | public async Task<Response> PerformMaintenanceAsync(string resourceGroupName, string vmScaleSetName, string inst |
| | 1194 | | { |
| 2 | 1195 | | if (resourceGroupName == null) |
| | 1196 | | { |
| 0 | 1197 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1198 | | } |
| 2 | 1199 | | if (vmScaleSetName == null) |
| | 1200 | | { |
| 0 | 1201 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1202 | | } |
| 2 | 1203 | | if (instanceId == null) |
| | 1204 | | { |
| 0 | 1205 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1206 | | } |
| | 1207 | |
|
| 2 | 1208 | | using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 2 | 1209 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1210 | | switch (message.Response.Status) |
| | 1211 | | { |
| | 1212 | | case 200: |
| | 1213 | | case 202: |
| 0 | 1214 | | return message.Response; |
| | 1215 | | default: |
| 2 | 1216 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1217 | | } |
| 0 | 1218 | | } |
| | 1219 | |
|
| | 1220 | | /// <summary> Performs maintenance on a virtual machine in a VM scale set. </summary> |
| | 1221 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1222 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1223 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1224 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1225 | | public Response PerformMaintenance(string resourceGroupName, string vmScaleSetName, string instanceId, Cancellat |
| | 1226 | | { |
| 2 | 1227 | | if (resourceGroupName == null) |
| | 1228 | | { |
| 0 | 1229 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1230 | | } |
| 2 | 1231 | | if (vmScaleSetName == null) |
| | 1232 | | { |
| 0 | 1233 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1234 | | } |
| 2 | 1235 | | if (instanceId == null) |
| | 1236 | | { |
| 0 | 1237 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1238 | | } |
| | 1239 | |
|
| 2 | 1240 | | using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 2 | 1241 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1242 | | switch (message.Response.Status) |
| | 1243 | | { |
| | 1244 | | case 200: |
| | 1245 | | case 202: |
| 0 | 1246 | | return message.Response; |
| | 1247 | | default: |
| 2 | 1248 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1249 | | } |
| 0 | 1250 | | } |
| | 1251 | |
|
| | 1252 | | internal HttpMessage CreateSimulateEvictionRequest(string resourceGroupName, string vmScaleSetName, string insta |
| | 1253 | | { |
| 0 | 1254 | | var message = _pipeline.CreateMessage(); |
| 0 | 1255 | | var request = message.Request; |
| 0 | 1256 | | request.Method = RequestMethod.Post; |
| 0 | 1257 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1258 | | uri.Reset(endpoint); |
| 0 | 1259 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1260 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1261 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1262 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1263 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 1264 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 1265 | | uri.AppendPath("/virtualMachines/", false); |
| 0 | 1266 | | uri.AppendPath(instanceId, true); |
| 0 | 1267 | | uri.AppendPath("/simulateEviction", false); |
| 0 | 1268 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 1269 | | request.Uri = uri; |
| 0 | 1270 | | return message; |
| | 1271 | | } |
| | 1272 | |
|
| | 1273 | | /// <summary> The operation to simulate the eviction of spot virtual machine in a VM scale set. The eviction wil |
| | 1274 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1275 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1276 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1277 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1278 | | public async Task<Response> SimulateEvictionAsync(string resourceGroupName, string vmScaleSetName, string instan |
| | 1279 | | { |
| 0 | 1280 | | if (resourceGroupName == null) |
| | 1281 | | { |
| 0 | 1282 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1283 | | } |
| 0 | 1284 | | if (vmScaleSetName == null) |
| | 1285 | | { |
| 0 | 1286 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1287 | | } |
| 0 | 1288 | | if (instanceId == null) |
| | 1289 | | { |
| 0 | 1290 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1291 | | } |
| | 1292 | |
|
| 0 | 1293 | | using var message = CreateSimulateEvictionRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 0 | 1294 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1295 | | switch (message.Response.Status) |
| | 1296 | | { |
| | 1297 | | case 204: |
| 0 | 1298 | | return message.Response; |
| | 1299 | | default: |
| 0 | 1300 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1301 | | } |
| 0 | 1302 | | } |
| | 1303 | |
|
| | 1304 | | /// <summary> The operation to simulate the eviction of spot virtual machine in a VM scale set. The eviction wil |
| | 1305 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1306 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1307 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1308 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1309 | | public Response SimulateEviction(string resourceGroupName, string vmScaleSetName, string instanceId, Cancellatio |
| | 1310 | | { |
| 0 | 1311 | | if (resourceGroupName == null) |
| | 1312 | | { |
| 0 | 1313 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1314 | | } |
| 0 | 1315 | | if (vmScaleSetName == null) |
| | 1316 | | { |
| 0 | 1317 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1318 | | } |
| 0 | 1319 | | if (instanceId == null) |
| | 1320 | | { |
| 0 | 1321 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1322 | | } |
| | 1323 | |
|
| 0 | 1324 | | using var message = CreateSimulateEvictionRequest(resourceGroupName, vmScaleSetName, instanceId); |
| 0 | 1325 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1326 | | switch (message.Response.Status) |
| | 1327 | | { |
| | 1328 | | case 204: |
| 0 | 1329 | | return message.Response; |
| | 1330 | | default: |
| 0 | 1331 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1332 | | } |
| 0 | 1333 | | } |
| | 1334 | |
|
| | 1335 | | internal HttpMessage CreateRunCommandRequest(string resourceGroupName, string vmScaleSetName, string instanceId, |
| | 1336 | | { |
| 8 | 1337 | | var message = _pipeline.CreateMessage(); |
| 8 | 1338 | | var request = message.Request; |
| 8 | 1339 | | request.Method = RequestMethod.Post; |
| 8 | 1340 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1341 | | uri.Reset(endpoint); |
| 8 | 1342 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 1343 | | uri.AppendPath(subscriptionId, true); |
| 8 | 1344 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 1345 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 1346 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 8 | 1347 | | uri.AppendPath(vmScaleSetName, true); |
| 8 | 1348 | | uri.AppendPath("/virtualmachines/", false); |
| 8 | 1349 | | uri.AppendPath(instanceId, true); |
| 8 | 1350 | | uri.AppendPath("/runCommand", false); |
| 8 | 1351 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 1352 | | request.Uri = uri; |
| 8 | 1353 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 1354 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1355 | | content.JsonWriter.WriteObjectValue(parameters); |
| 8 | 1356 | | request.Content = content; |
| 8 | 1357 | | return message; |
| | 1358 | | } |
| | 1359 | |
|
| | 1360 | | /// <summary> Run command on a virtual machine in a VM scale set. </summary> |
| | 1361 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1362 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1363 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1364 | | /// <param name="parameters"> Parameters supplied to the Run command operation. </param> |
| | 1365 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1366 | | public async Task<Response> RunCommandAsync(string resourceGroupName, string vmScaleSetName, string instanceId, |
| | 1367 | | { |
| 2 | 1368 | | if (resourceGroupName == null) |
| | 1369 | | { |
| 0 | 1370 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1371 | | } |
| 2 | 1372 | | if (vmScaleSetName == null) |
| | 1373 | | { |
| 0 | 1374 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1375 | | } |
| 2 | 1376 | | if (instanceId == null) |
| | 1377 | | { |
| 0 | 1378 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1379 | | } |
| 2 | 1380 | | if (parameters == null) |
| | 1381 | | { |
| 0 | 1382 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1383 | | } |
| | 1384 | |
|
| 2 | 1385 | | using var message = CreateRunCommandRequest(resourceGroupName, vmScaleSetName, instanceId, parameters); |
| 2 | 1386 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1387 | | switch (message.Response.Status) |
| | 1388 | | { |
| | 1389 | | case 200: |
| | 1390 | | case 202: |
| 2 | 1391 | | return message.Response; |
| | 1392 | | default: |
| 0 | 1393 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1394 | | } |
| 2 | 1395 | | } |
| | 1396 | |
|
| | 1397 | | /// <summary> Run command on a virtual machine in a VM scale set. </summary> |
| | 1398 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1399 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1400 | | /// <param name="instanceId"> The instance ID of the virtual machine. </param> |
| | 1401 | | /// <param name="parameters"> Parameters supplied to the Run command operation. </param> |
| | 1402 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1403 | | public Response RunCommand(string resourceGroupName, string vmScaleSetName, string instanceId, RunCommandInput p |
| | 1404 | | { |
| 2 | 1405 | | if (resourceGroupName == null) |
| | 1406 | | { |
| 0 | 1407 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1408 | | } |
| 2 | 1409 | | if (vmScaleSetName == null) |
| | 1410 | | { |
| 0 | 1411 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1412 | | } |
| 2 | 1413 | | if (instanceId == null) |
| | 1414 | | { |
| 0 | 1415 | | throw new ArgumentNullException(nameof(instanceId)); |
| | 1416 | | } |
| 2 | 1417 | | if (parameters == null) |
| | 1418 | | { |
| 0 | 1419 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1420 | | } |
| | 1421 | |
|
| 2 | 1422 | | using var message = CreateRunCommandRequest(resourceGroupName, vmScaleSetName, instanceId, parameters); |
| 2 | 1423 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1424 | | switch (message.Response.Status) |
| | 1425 | | { |
| | 1426 | | case 200: |
| | 1427 | | case 202: |
| 2 | 1428 | | return message.Response; |
| | 1429 | | default: |
| 0 | 1430 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1431 | | } |
| 2 | 1432 | | } |
| | 1433 | |
|
| | 1434 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string virtualMachineS |
| | 1435 | | { |
| 0 | 1436 | | var message = _pipeline.CreateMessage(); |
| 0 | 1437 | | var request = message.Request; |
| 0 | 1438 | | request.Method = RequestMethod.Get; |
| 0 | 1439 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1440 | | uri.Reset(endpoint); |
| 0 | 1441 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1442 | | request.Uri = uri; |
| 0 | 1443 | | return message; |
| | 1444 | | } |
| | 1445 | |
|
| | 1446 | | /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary> |
| | 1447 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1448 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1449 | | /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param> |
| | 1450 | | /// <param name="filter"> The filter to apply to the operation. </param> |
| | 1451 | | /// <param name="select"> The list parameters. </param> |
| | 1452 | | /// <param name="expand"> The expand expression to apply to the operation. </param> |
| | 1453 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1454 | | public async Task<Response<VirtualMachineScaleSetVMListResult>> ListNextPageAsync(string nextLink, string resour |
| | 1455 | | { |
| 0 | 1456 | | if (nextLink == null) |
| | 1457 | | { |
| 0 | 1458 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1459 | | } |
| 0 | 1460 | | if (resourceGroupName == null) |
| | 1461 | | { |
| 0 | 1462 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1463 | | } |
| 0 | 1464 | | if (virtualMachineScaleSetName == null) |
| | 1465 | | { |
| 0 | 1466 | | throw new ArgumentNullException(nameof(virtualMachineScaleSetName)); |
| | 1467 | | } |
| | 1468 | |
|
| 0 | 1469 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualMachineScaleSetName, filte |
| 0 | 1470 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1471 | | switch (message.Response.Status) |
| | 1472 | | { |
| | 1473 | | case 200: |
| | 1474 | | { |
| 0 | 1475 | | VirtualMachineScaleSetVMListResult value = default; |
| 0 | 1476 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1477 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1478 | | { |
| 0 | 1479 | | value = null; |
| | 1480 | | } |
| | 1481 | | else |
| | 1482 | | { |
| 0 | 1483 | | value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc |
| | 1484 | | } |
| 0 | 1485 | | return Response.FromValue(value, message.Response); |
| | 1486 | | } |
| | 1487 | | default: |
| 0 | 1488 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1489 | | } |
| 0 | 1490 | | } |
| | 1491 | |
|
| | 1492 | | /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary> |
| | 1493 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1494 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1495 | | /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param> |
| | 1496 | | /// <param name="filter"> The filter to apply to the operation. </param> |
| | 1497 | | /// <param name="select"> The list parameters. </param> |
| | 1498 | | /// <param name="expand"> The expand expression to apply to the operation. </param> |
| | 1499 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1500 | | public Response<VirtualMachineScaleSetVMListResult> ListNextPage(string nextLink, string resourceGroupName, stri |
| | 1501 | | { |
| 0 | 1502 | | if (nextLink == null) |
| | 1503 | | { |
| 0 | 1504 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1505 | | } |
| 0 | 1506 | | if (resourceGroupName == null) |
| | 1507 | | { |
| 0 | 1508 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1509 | | } |
| 0 | 1510 | | if (virtualMachineScaleSetName == null) |
| | 1511 | | { |
| 0 | 1512 | | throw new ArgumentNullException(nameof(virtualMachineScaleSetName)); |
| | 1513 | | } |
| | 1514 | |
|
| 0 | 1515 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualMachineScaleSetName, filte |
| 0 | 1516 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1517 | | switch (message.Response.Status) |
| | 1518 | | { |
| | 1519 | | case 200: |
| | 1520 | | { |
| 0 | 1521 | | VirtualMachineScaleSetVMListResult value = default; |
| 0 | 1522 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1523 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1524 | | { |
| 0 | 1525 | | value = null; |
| | 1526 | | } |
| | 1527 | | else |
| | 1528 | | { |
| 0 | 1529 | | value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc |
| | 1530 | | } |
| 0 | 1531 | | return Response.FromValue(value, message.Response); |
| | 1532 | | } |
| | 1533 | | default: |
| 0 | 1534 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1535 | | } |
| 0 | 1536 | | } |
| | 1537 | | } |
| | 1538 | | } |