| | 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 VirtualMachineScaleSetsRestOperations |
| | 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 VirtualMachineScaleSetsRestOperations. </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 VirtualMachineScaleSetsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string |
| | 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 CreateCreateOrUpdateRequest(string resourceGroupName, string vmScaleSetName, VirtualMachine |
| | 47 | | { |
| 364 | 48 | | var message = _pipeline.CreateMessage(); |
| 364 | 49 | | var request = message.Request; |
| 364 | 50 | | request.Method = RequestMethod.Put; |
| 364 | 51 | | var uri = new RawRequestUriBuilder(); |
| 364 | 52 | | uri.Reset(endpoint); |
| 364 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 364 | 54 | | uri.AppendPath(subscriptionId, true); |
| 364 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 364 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 364 | 57 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 364 | 58 | | uri.AppendPath(vmScaleSetName, true); |
| 364 | 59 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 364 | 60 | | request.Uri = uri; |
| 364 | 61 | | request.Headers.Add("Content-Type", "application/json"); |
| 364 | 62 | | var content = new Utf8JsonRequestContent(); |
| 364 | 63 | | content.JsonWriter.WriteObjectValue(parameters); |
| 364 | 64 | | request.Content = content; |
| 364 | 65 | | return message; |
| | 66 | | } |
| | 67 | |
|
| | 68 | | /// <summary> Create or update a VM scale set. </summary> |
| | 69 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 70 | | /// <param name="vmScaleSetName"> The name of the VM scale set to create or update. </param> |
| | 71 | | /// <param name="parameters"> The scale set object. </param> |
| | 72 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 73 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineS |
| | 74 | | { |
| 92 | 75 | | if (resourceGroupName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 78 | | } |
| 92 | 79 | | if (vmScaleSetName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 82 | | } |
| 92 | 83 | | if (parameters == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(parameters)); |
| | 86 | | } |
| | 87 | |
|
| 92 | 88 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, vmScaleSetName, parameters); |
| 92 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 90 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | case 201: |
| 90 | 94 | | return message.Response; |
| | 95 | | default: |
| 0 | 96 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 97 | | } |
| 90 | 98 | | } |
| | 99 | |
|
| | 100 | | /// <summary> Create or update a VM scale set. </summary> |
| | 101 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 102 | | /// <param name="vmScaleSetName"> The name of the VM scale set to create or update. </param> |
| | 103 | | /// <param name="parameters"> The scale set object. </param> |
| | 104 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 105 | | public Response CreateOrUpdate(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSet parameter |
| | 106 | | { |
| 92 | 107 | | if (resourceGroupName == null) |
| | 108 | | { |
| 0 | 109 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 110 | | } |
| 92 | 111 | | if (vmScaleSetName == null) |
| | 112 | | { |
| 0 | 113 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 114 | | } |
| 92 | 115 | | if (parameters == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(parameters)); |
| | 118 | | } |
| | 119 | |
|
| 92 | 120 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, vmScaleSetName, parameters); |
| 92 | 121 | | _pipeline.Send(message, cancellationToken); |
| 90 | 122 | | switch (message.Response.Status) |
| | 123 | | { |
| | 124 | | case 200: |
| | 125 | | case 201: |
| 90 | 126 | | return message.Response; |
| | 127 | | default: |
| 0 | 128 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 129 | | } |
| 90 | 130 | | } |
| | 131 | |
|
| | 132 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSet |
| | 133 | | { |
| 0 | 134 | | var message = _pipeline.CreateMessage(); |
| 0 | 135 | | var request = message.Request; |
| 0 | 136 | | request.Method = RequestMethod.Patch; |
| 0 | 137 | | var uri = new RawRequestUriBuilder(); |
| 0 | 138 | | uri.Reset(endpoint); |
| 0 | 139 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 140 | | uri.AppendPath(subscriptionId, true); |
| 0 | 141 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 142 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 143 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 144 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 145 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 146 | | request.Uri = uri; |
| 0 | 147 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 148 | | var content = new Utf8JsonRequestContent(); |
| 0 | 149 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 150 | | request.Content = content; |
| 0 | 151 | | return message; |
| | 152 | | } |
| | 153 | |
|
| | 154 | | /// <summary> Update a VM scale set. </summary> |
| | 155 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 156 | | /// <param name="vmScaleSetName"> The name of the VM scale set to create or update. </param> |
| | 157 | | /// <param name="parameters"> The scale set object. </param> |
| | 158 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 159 | | public async Task<Response> UpdateAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetU |
| | 160 | | { |
| 0 | 161 | | if (resourceGroupName == null) |
| | 162 | | { |
| 0 | 163 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 164 | | } |
| 0 | 165 | | if (vmScaleSetName == null) |
| | 166 | | { |
| 0 | 167 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 168 | | } |
| 0 | 169 | | if (parameters == null) |
| | 170 | | { |
| 0 | 171 | | throw new ArgumentNullException(nameof(parameters)); |
| | 172 | | } |
| | 173 | |
|
| 0 | 174 | | using var message = CreateUpdateRequest(resourceGroupName, vmScaleSetName, parameters); |
| 0 | 175 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 176 | | switch (message.Response.Status) |
| | 177 | | { |
| | 178 | | case 200: |
| 0 | 179 | | return message.Response; |
| | 180 | | default: |
| 0 | 181 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 182 | | } |
| 0 | 183 | | } |
| | 184 | |
|
| | 185 | | /// <summary> Update a VM scale set. </summary> |
| | 186 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 187 | | /// <param name="vmScaleSetName"> The name of the VM scale set to create or update. </param> |
| | 188 | | /// <param name="parameters"> The scale set object. </param> |
| | 189 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 190 | | public Response Update(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetUpdate parameters, |
| | 191 | | { |
| 0 | 192 | | if (resourceGroupName == null) |
| | 193 | | { |
| 0 | 194 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 195 | | } |
| 0 | 196 | | if (vmScaleSetName == null) |
| | 197 | | { |
| 0 | 198 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 199 | | } |
| 0 | 200 | | if (parameters == null) |
| | 201 | | { |
| 0 | 202 | | throw new ArgumentNullException(nameof(parameters)); |
| | 203 | | } |
| | 204 | |
|
| 0 | 205 | | using var message = CreateUpdateRequest(resourceGroupName, vmScaleSetName, parameters); |
| 0 | 206 | | _pipeline.Send(message, cancellationToken); |
| 0 | 207 | | switch (message.Response.Status) |
| | 208 | | { |
| | 209 | | case 200: |
| 0 | 210 | | return message.Response; |
| | 211 | | default: |
| 0 | 212 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 213 | | } |
| 0 | 214 | | } |
| | 215 | |
|
| | 216 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string vmScaleSetName) |
| | 217 | | { |
| 248 | 218 | | var message = _pipeline.CreateMessage(); |
| 248 | 219 | | var request = message.Request; |
| 248 | 220 | | request.Method = RequestMethod.Delete; |
| 248 | 221 | | var uri = new RawRequestUriBuilder(); |
| 248 | 222 | | uri.Reset(endpoint); |
| 248 | 223 | | uri.AppendPath("/subscriptions/", false); |
| 248 | 224 | | uri.AppendPath(subscriptionId, true); |
| 248 | 225 | | uri.AppendPath("/resourceGroups/", false); |
| 248 | 226 | | uri.AppendPath(resourceGroupName, true); |
| 248 | 227 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 248 | 228 | | uri.AppendPath(vmScaleSetName, true); |
| 248 | 229 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 248 | 230 | | request.Uri = uri; |
| 248 | 231 | | return message; |
| | 232 | | } |
| | 233 | |
|
| | 234 | | /// <summary> Deletes a VM scale set. </summary> |
| | 235 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 236 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 237 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 238 | | public async Task<Response> DeleteAsync(string resourceGroupName, string vmScaleSetName, CancellationToken cance |
| | 239 | | { |
| 62 | 240 | | if (resourceGroupName == null) |
| | 241 | | { |
| 0 | 242 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 243 | | } |
| 62 | 244 | | if (vmScaleSetName == null) |
| | 245 | | { |
| 0 | 246 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 247 | | } |
| | 248 | |
|
| 62 | 249 | | using var message = CreateDeleteRequest(resourceGroupName, vmScaleSetName); |
| 62 | 250 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 62 | 251 | | switch (message.Response.Status) |
| | 252 | | { |
| | 253 | | case 200: |
| | 254 | | case 202: |
| | 255 | | case 204: |
| 62 | 256 | | return message.Response; |
| | 257 | | default: |
| 0 | 258 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 259 | | } |
| 62 | 260 | | } |
| | 261 | |
|
| | 262 | | /// <summary> Deletes a VM scale set. </summary> |
| | 263 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 264 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 265 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 266 | | public Response Delete(string resourceGroupName, string vmScaleSetName, CancellationToken cancellationToken = de |
| | 267 | | { |
| 62 | 268 | | if (resourceGroupName == null) |
| | 269 | | { |
| 0 | 270 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 271 | | } |
| 62 | 272 | | if (vmScaleSetName == null) |
| | 273 | | { |
| 0 | 274 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 275 | | } |
| | 276 | |
|
| 62 | 277 | | using var message = CreateDeleteRequest(resourceGroupName, vmScaleSetName); |
| 62 | 278 | | _pipeline.Send(message, cancellationToken); |
| 62 | 279 | | switch (message.Response.Status) |
| | 280 | | { |
| | 281 | | case 200: |
| | 282 | | case 202: |
| | 283 | | case 204: |
| 62 | 284 | | return message.Response; |
| | 285 | | default: |
| 0 | 286 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 287 | | } |
| 62 | 288 | | } |
| | 289 | |
|
| | 290 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string vmScaleSetName) |
| | 291 | | { |
| 220 | 292 | | var message = _pipeline.CreateMessage(); |
| 220 | 293 | | var request = message.Request; |
| 220 | 294 | | request.Method = RequestMethod.Get; |
| 220 | 295 | | var uri = new RawRequestUriBuilder(); |
| 220 | 296 | | uri.Reset(endpoint); |
| 220 | 297 | | uri.AppendPath("/subscriptions/", false); |
| 220 | 298 | | uri.AppendPath(subscriptionId, true); |
| 220 | 299 | | uri.AppendPath("/resourceGroups/", false); |
| 220 | 300 | | uri.AppendPath(resourceGroupName, true); |
| 220 | 301 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 220 | 302 | | uri.AppendPath(vmScaleSetName, true); |
| 220 | 303 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 220 | 304 | | request.Uri = uri; |
| 220 | 305 | | return message; |
| | 306 | | } |
| | 307 | |
|
| | 308 | | /// <summary> Display information about a virtual machine scale set. </summary> |
| | 309 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 310 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 311 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 312 | | public async Task<Response<VirtualMachineScaleSet>> GetAsync(string resourceGroupName, string vmScaleSetName, Ca |
| | 313 | | { |
| 110 | 314 | | if (resourceGroupName == null) |
| | 315 | | { |
| 0 | 316 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 317 | | } |
| 110 | 318 | | if (vmScaleSetName == null) |
| | 319 | | { |
| 0 | 320 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 321 | | } |
| | 322 | |
|
| 110 | 323 | | using var message = CreateGetRequest(resourceGroupName, vmScaleSetName); |
| 110 | 324 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 110 | 325 | | switch (message.Response.Status) |
| | 326 | | { |
| | 327 | | case 200: |
| | 328 | | { |
| 110 | 329 | | VirtualMachineScaleSet value = default; |
| 110 | 330 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 110 | 331 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 332 | | { |
| 0 | 333 | | value = null; |
| | 334 | | } |
| | 335 | | else |
| | 336 | | { |
| 110 | 337 | | value = VirtualMachineScaleSet.DeserializeVirtualMachineScaleSet(document.RootElement); |
| | 338 | | } |
| 110 | 339 | | return Response.FromValue(value, message.Response); |
| | 340 | | } |
| | 341 | | default: |
| 0 | 342 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 343 | | } |
| 110 | 344 | | } |
| | 345 | |
|
| | 346 | | /// <summary> Display information about a virtual machine scale set. </summary> |
| | 347 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 348 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 349 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 350 | | public Response<VirtualMachineScaleSet> Get(string resourceGroupName, string vmScaleSetName, CancellationToken c |
| | 351 | | { |
| 110 | 352 | | if (resourceGroupName == null) |
| | 353 | | { |
| 0 | 354 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 355 | | } |
| 110 | 356 | | if (vmScaleSetName == null) |
| | 357 | | { |
| 0 | 358 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 359 | | } |
| | 360 | |
|
| 110 | 361 | | using var message = CreateGetRequest(resourceGroupName, vmScaleSetName); |
| 110 | 362 | | _pipeline.Send(message, cancellationToken); |
| 110 | 363 | | switch (message.Response.Status) |
| | 364 | | { |
| | 365 | | case 200: |
| | 366 | | { |
| 110 | 367 | | VirtualMachineScaleSet value = default; |
| 110 | 368 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 110 | 369 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 370 | | { |
| 0 | 371 | | value = null; |
| | 372 | | } |
| | 373 | | else |
| | 374 | | { |
| 110 | 375 | | value = VirtualMachineScaleSet.DeserializeVirtualMachineScaleSet(document.RootElement); |
| | 376 | | } |
| 110 | 377 | | return Response.FromValue(value, message.Response); |
| | 378 | | } |
| | 379 | | default: |
| 0 | 380 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 381 | | } |
| 110 | 382 | | } |
| | 383 | |
|
| | 384 | | internal HttpMessage CreateDeallocateRequest(string resourceGroupName, string vmScaleSetName, VirtualMachineScal |
| | 385 | | { |
| 24 | 386 | | var message = _pipeline.CreateMessage(); |
| 24 | 387 | | var request = message.Request; |
| 24 | 388 | | request.Method = RequestMethod.Post; |
| 24 | 389 | | var uri = new RawRequestUriBuilder(); |
| 24 | 390 | | uri.Reset(endpoint); |
| 24 | 391 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 392 | | uri.AppendPath(subscriptionId, true); |
| 24 | 393 | | uri.AppendPath("/resourceGroups/", false); |
| 24 | 394 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 395 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 24 | 396 | | uri.AppendPath(vmScaleSetName, true); |
| 24 | 397 | | uri.AppendPath("/deallocate", false); |
| 24 | 398 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 24 | 399 | | request.Uri = uri; |
| 24 | 400 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 401 | | if (vmInstanceIDs != null) |
| | 402 | | { |
| 8 | 403 | | var content = new Utf8JsonRequestContent(); |
| 8 | 404 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 405 | | request.Content = content; |
| | 406 | | } |
| 24 | 407 | | return message; |
| | 408 | | } |
| | 409 | |
|
| | 410 | | /// <summary> Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and relea |
| | 411 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 412 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 413 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 414 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 415 | | public async Task<Response> DeallocateAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineScale |
| | 416 | | { |
| 6 | 417 | | if (resourceGroupName == null) |
| | 418 | | { |
| 0 | 419 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 420 | | } |
| 6 | 421 | | if (vmScaleSetName == null) |
| | 422 | | { |
| 0 | 423 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 424 | | } |
| | 425 | |
|
| 6 | 426 | | using var message = CreateDeallocateRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 6 | 427 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 428 | | switch (message.Response.Status) |
| | 429 | | { |
| | 430 | | case 200: |
| | 431 | | case 202: |
| 6 | 432 | | return message.Response; |
| | 433 | | default: |
| 0 | 434 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 435 | | } |
| 6 | 436 | | } |
| | 437 | |
|
| | 438 | | /// <summary> Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and relea |
| | 439 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 440 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 441 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 442 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 443 | | public Response Deallocate(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInstanceIDs |
| | 444 | | { |
| 6 | 445 | | if (resourceGroupName == null) |
| | 446 | | { |
| 0 | 447 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 448 | | } |
| 6 | 449 | | if (vmScaleSetName == null) |
| | 450 | | { |
| 0 | 451 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 452 | | } |
| | 453 | |
|
| 6 | 454 | | using var message = CreateDeallocateRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 6 | 455 | | _pipeline.Send(message, cancellationToken); |
| 6 | 456 | | switch (message.Response.Status) |
| | 457 | | { |
| | 458 | | case 200: |
| | 459 | | case 202: |
| 6 | 460 | | return message.Response; |
| | 461 | | default: |
| 0 | 462 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 463 | | } |
| 6 | 464 | | } |
| | 465 | |
|
| | 466 | | internal HttpMessage CreateDeleteInstancesRequest(string resourceGroupName, string vmScaleSetName, VirtualMachin |
| | 467 | | { |
| 8 | 468 | | var message = _pipeline.CreateMessage(); |
| 8 | 469 | | var request = message.Request; |
| 8 | 470 | | request.Method = RequestMethod.Post; |
| 8 | 471 | | var uri = new RawRequestUriBuilder(); |
| 8 | 472 | | uri.Reset(endpoint); |
| 8 | 473 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 474 | | uri.AppendPath(subscriptionId, true); |
| 8 | 475 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 476 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 477 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 8 | 478 | | uri.AppendPath(vmScaleSetName, true); |
| 8 | 479 | | uri.AppendPath("/delete", false); |
| 8 | 480 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 481 | | request.Uri = uri; |
| 8 | 482 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 483 | | var content = new Utf8JsonRequestContent(); |
| 8 | 484 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 485 | | request.Content = content; |
| 8 | 486 | | return message; |
| | 487 | | } |
| | 488 | |
|
| | 489 | | /// <summary> Deletes virtual machines in a VM scale set. </summary> |
| | 490 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 491 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 492 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 493 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 494 | | public async Task<Response> DeleteInstancesAsync(string resourceGroupName, string vmScaleSetName, VirtualMachine |
| | 495 | | { |
| 2 | 496 | | if (resourceGroupName == null) |
| | 497 | | { |
| 0 | 498 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 499 | | } |
| 2 | 500 | | if (vmScaleSetName == null) |
| | 501 | | { |
| 0 | 502 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 503 | | } |
| 2 | 504 | | if (vmInstanceIDs == null) |
| | 505 | | { |
| 0 | 506 | | throw new ArgumentNullException(nameof(vmInstanceIDs)); |
| | 507 | | } |
| | 508 | |
|
| 2 | 509 | | using var message = CreateDeleteInstancesRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 2 | 510 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 511 | | switch (message.Response.Status) |
| | 512 | | { |
| | 513 | | case 200: |
| | 514 | | case 202: |
| 2 | 515 | | return message.Response; |
| | 516 | | default: |
| 0 | 517 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 518 | | } |
| 2 | 519 | | } |
| | 520 | |
|
| | 521 | | /// <summary> Deletes virtual machines in a VM scale set. </summary> |
| | 522 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 523 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 524 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 525 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 526 | | public Response DeleteInstances(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInstanc |
| | 527 | | { |
| 2 | 528 | | if (resourceGroupName == null) |
| | 529 | | { |
| 0 | 530 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 531 | | } |
| 2 | 532 | | if (vmScaleSetName == null) |
| | 533 | | { |
| 0 | 534 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 535 | | } |
| 2 | 536 | | if (vmInstanceIDs == null) |
| | 537 | | { |
| 0 | 538 | | throw new ArgumentNullException(nameof(vmInstanceIDs)); |
| | 539 | | } |
| | 540 | |
|
| 2 | 541 | | using var message = CreateDeleteInstancesRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 2 | 542 | | _pipeline.Send(message, cancellationToken); |
| 2 | 543 | | switch (message.Response.Status) |
| | 544 | | { |
| | 545 | | case 200: |
| | 546 | | case 202: |
| 2 | 547 | | return message.Response; |
| | 548 | | default: |
| 0 | 549 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 550 | | } |
| 2 | 551 | | } |
| | 552 | |
|
| | 553 | | internal HttpMessage CreateGetInstanceViewRequest(string resourceGroupName, string vmScaleSetName) |
| | 554 | | { |
| 60 | 555 | | var message = _pipeline.CreateMessage(); |
| 60 | 556 | | var request = message.Request; |
| 60 | 557 | | request.Method = RequestMethod.Get; |
| 60 | 558 | | var uri = new RawRequestUriBuilder(); |
| 60 | 559 | | uri.Reset(endpoint); |
| 60 | 560 | | uri.AppendPath("/subscriptions/", false); |
| 60 | 561 | | uri.AppendPath(subscriptionId, true); |
| 60 | 562 | | uri.AppendPath("/resourceGroups/", false); |
| 60 | 563 | | uri.AppendPath(resourceGroupName, true); |
| 60 | 564 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 60 | 565 | | uri.AppendPath(vmScaleSetName, true); |
| 60 | 566 | | uri.AppendPath("/instanceView", false); |
| 60 | 567 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 60 | 568 | | request.Uri = uri; |
| 60 | 569 | | return message; |
| | 570 | | } |
| | 571 | |
|
| | 572 | | /// <summary> Gets the status of a VM scale set instance. </summary> |
| | 573 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 574 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 575 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 576 | | public async Task<Response<VirtualMachineScaleSetInstanceView>> GetInstanceViewAsync(string resourceGroupName, s |
| | 577 | | { |
| 30 | 578 | | if (resourceGroupName == null) |
| | 579 | | { |
| 0 | 580 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 581 | | } |
| 30 | 582 | | if (vmScaleSetName == null) |
| | 583 | | { |
| 0 | 584 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 585 | | } |
| | 586 | |
|
| 30 | 587 | | using var message = CreateGetInstanceViewRequest(resourceGroupName, vmScaleSetName); |
| 30 | 588 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 30 | 589 | | switch (message.Response.Status) |
| | 590 | | { |
| | 591 | | case 200: |
| | 592 | | { |
| 30 | 593 | | VirtualMachineScaleSetInstanceView value = default; |
| 30 | 594 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 30 | 595 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 596 | | { |
| 0 | 597 | | value = null; |
| | 598 | | } |
| | 599 | | else |
| | 600 | | { |
| 30 | 601 | | value = VirtualMachineScaleSetInstanceView.DeserializeVirtualMachineScaleSetInstanceView(doc |
| | 602 | | } |
| 30 | 603 | | return Response.FromValue(value, message.Response); |
| | 604 | | } |
| | 605 | | default: |
| 0 | 606 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 607 | | } |
| 30 | 608 | | } |
| | 609 | |
|
| | 610 | | /// <summary> Gets the status of a VM scale set instance. </summary> |
| | 611 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 612 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 613 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 614 | | public Response<VirtualMachineScaleSetInstanceView> GetInstanceView(string resourceGroupName, string vmScaleSetN |
| | 615 | | { |
| 30 | 616 | | if (resourceGroupName == null) |
| | 617 | | { |
| 0 | 618 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 619 | | } |
| 30 | 620 | | if (vmScaleSetName == null) |
| | 621 | | { |
| 0 | 622 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 623 | | } |
| | 624 | |
|
| 30 | 625 | | using var message = CreateGetInstanceViewRequest(resourceGroupName, vmScaleSetName); |
| 30 | 626 | | _pipeline.Send(message, cancellationToken); |
| 30 | 627 | | switch (message.Response.Status) |
| | 628 | | { |
| | 629 | | case 200: |
| | 630 | | { |
| 30 | 631 | | VirtualMachineScaleSetInstanceView value = default; |
| 30 | 632 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 30 | 633 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 634 | | { |
| 0 | 635 | | value = null; |
| | 636 | | } |
| | 637 | | else |
| | 638 | | { |
| 30 | 639 | | value = VirtualMachineScaleSetInstanceView.DeserializeVirtualMachineScaleSetInstanceView(doc |
| | 640 | | } |
| 30 | 641 | | return Response.FromValue(value, message.Response); |
| | 642 | | } |
| | 643 | | default: |
| 0 | 644 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 645 | | } |
| 30 | 646 | | } |
| | 647 | |
|
| | 648 | | internal HttpMessage CreateListRequest(string resourceGroupName) |
| | 649 | | { |
| 48 | 650 | | var message = _pipeline.CreateMessage(); |
| 48 | 651 | | var request = message.Request; |
| 48 | 652 | | request.Method = RequestMethod.Get; |
| 48 | 653 | | var uri = new RawRequestUriBuilder(); |
| 48 | 654 | | uri.Reset(endpoint); |
| 48 | 655 | | uri.AppendPath("/subscriptions/", false); |
| 48 | 656 | | uri.AppendPath(subscriptionId, true); |
| 48 | 657 | | uri.AppendPath("/resourceGroups/", false); |
| 48 | 658 | | uri.AppendPath(resourceGroupName, true); |
| 48 | 659 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets", false); |
| 48 | 660 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 48 | 661 | | request.Uri = uri; |
| 48 | 662 | | return message; |
| | 663 | | } |
| | 664 | |
|
| | 665 | | /// <summary> Gets a list of all VM scale sets under a resource group. </summary> |
| | 666 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 667 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 668 | | public async Task<Response<VirtualMachineScaleSetListResult>> ListAsync(string resourceGroupName, CancellationTo |
| | 669 | | { |
| 24 | 670 | | if (resourceGroupName == null) |
| | 671 | | { |
| 0 | 672 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 673 | | } |
| | 674 | |
|
| 24 | 675 | | using var message = CreateListRequest(resourceGroupName); |
| 24 | 676 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 24 | 677 | | switch (message.Response.Status) |
| | 678 | | { |
| | 679 | | case 200: |
| | 680 | | { |
| 24 | 681 | | VirtualMachineScaleSetListResult value = default; |
| 24 | 682 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 24 | 683 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 684 | | { |
| 0 | 685 | | value = null; |
| | 686 | | } |
| | 687 | | else |
| | 688 | | { |
| 24 | 689 | | value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(documen |
| | 690 | | } |
| 24 | 691 | | return Response.FromValue(value, message.Response); |
| | 692 | | } |
| | 693 | | default: |
| 0 | 694 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 695 | | } |
| 24 | 696 | | } |
| | 697 | |
|
| | 698 | | /// <summary> Gets a list of all VM scale sets under a resource group. </summary> |
| | 699 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 700 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 701 | | public Response<VirtualMachineScaleSetListResult> List(string resourceGroupName, CancellationToken cancellationT |
| | 702 | | { |
| 24 | 703 | | if (resourceGroupName == null) |
| | 704 | | { |
| 0 | 705 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 706 | | } |
| | 707 | |
|
| 24 | 708 | | using var message = CreateListRequest(resourceGroupName); |
| 24 | 709 | | _pipeline.Send(message, cancellationToken); |
| 24 | 710 | | switch (message.Response.Status) |
| | 711 | | { |
| | 712 | | case 200: |
| | 713 | | { |
| 24 | 714 | | VirtualMachineScaleSetListResult value = default; |
| 24 | 715 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 24 | 716 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 717 | | { |
| 0 | 718 | | value = null; |
| | 719 | | } |
| | 720 | | else |
| | 721 | | { |
| 24 | 722 | | value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(documen |
| | 723 | | } |
| 24 | 724 | | return Response.FromValue(value, message.Response); |
| | 725 | | } |
| | 726 | | default: |
| 0 | 727 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 728 | | } |
| 24 | 729 | | } |
| | 730 | |
|
| | 731 | | internal HttpMessage CreateListAllRequest() |
| | 732 | | { |
| 0 | 733 | | var message = _pipeline.CreateMessage(); |
| 0 | 734 | | var request = message.Request; |
| 0 | 735 | | request.Method = RequestMethod.Get; |
| 0 | 736 | | var uri = new RawRequestUriBuilder(); |
| 0 | 737 | | uri.Reset(endpoint); |
| 0 | 738 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 739 | | uri.AppendPath(subscriptionId, true); |
| 0 | 740 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets", false); |
| 0 | 741 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 742 | | request.Uri = uri; |
| 0 | 743 | | return message; |
| | 744 | | } |
| | 745 | |
|
| | 746 | | /// <summary> Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. |
| | 747 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 748 | | public async Task<Response<VirtualMachineScaleSetListWithLinkResult>> ListAllAsync(CancellationToken cancellatio |
| | 749 | | { |
| 0 | 750 | | using var message = CreateListAllRequest(); |
| 0 | 751 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 752 | | switch (message.Response.Status) |
| | 753 | | { |
| | 754 | | case 200: |
| | 755 | | { |
| 0 | 756 | | VirtualMachineScaleSetListWithLinkResult value = default; |
| 0 | 757 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 758 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 759 | | { |
| 0 | 760 | | value = null; |
| | 761 | | } |
| | 762 | | else |
| | 763 | | { |
| 0 | 764 | | value = VirtualMachineScaleSetListWithLinkResult.DeserializeVirtualMachineScaleSetListWithLi |
| | 765 | | } |
| 0 | 766 | | return Response.FromValue(value, message.Response); |
| | 767 | | } |
| | 768 | | default: |
| 0 | 769 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 770 | | } |
| 0 | 771 | | } |
| | 772 | |
|
| | 773 | | /// <summary> Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. |
| | 774 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 775 | | public Response<VirtualMachineScaleSetListWithLinkResult> ListAll(CancellationToken cancellationToken = default) |
| | 776 | | { |
| 0 | 777 | | using var message = CreateListAllRequest(); |
| 0 | 778 | | _pipeline.Send(message, cancellationToken); |
| 0 | 779 | | switch (message.Response.Status) |
| | 780 | | { |
| | 781 | | case 200: |
| | 782 | | { |
| 0 | 783 | | VirtualMachineScaleSetListWithLinkResult value = default; |
| 0 | 784 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 785 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 786 | | { |
| 0 | 787 | | value = null; |
| | 788 | | } |
| | 789 | | else |
| | 790 | | { |
| 0 | 791 | | value = VirtualMachineScaleSetListWithLinkResult.DeserializeVirtualMachineScaleSetListWithLi |
| | 792 | | } |
| 0 | 793 | | return Response.FromValue(value, message.Response); |
| | 794 | | } |
| | 795 | | default: |
| 0 | 796 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 797 | | } |
| 0 | 798 | | } |
| | 799 | |
|
| | 800 | | internal HttpMessage CreateListSkusRequest(string resourceGroupName, string vmScaleSetName) |
| | 801 | | { |
| 48 | 802 | | var message = _pipeline.CreateMessage(); |
| 48 | 803 | | var request = message.Request; |
| 48 | 804 | | request.Method = RequestMethod.Get; |
| 48 | 805 | | var uri = new RawRequestUriBuilder(); |
| 48 | 806 | | uri.Reset(endpoint); |
| 48 | 807 | | uri.AppendPath("/subscriptions/", false); |
| 48 | 808 | | uri.AppendPath(subscriptionId, true); |
| 48 | 809 | | uri.AppendPath("/resourceGroups/", false); |
| 48 | 810 | | uri.AppendPath(resourceGroupName, true); |
| 48 | 811 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 48 | 812 | | uri.AppendPath(vmScaleSetName, true); |
| 48 | 813 | | uri.AppendPath("/skus", false); |
| 48 | 814 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 48 | 815 | | request.Uri = uri; |
| 48 | 816 | | return message; |
| | 817 | | } |
| | 818 | |
|
| | 819 | | /// <summary> Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instance |
| | 820 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 821 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 822 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 823 | | public async Task<Response<VirtualMachineScaleSetListSkusResult>> ListSkusAsync(string resourceGroupName, string |
| | 824 | | { |
| 24 | 825 | | if (resourceGroupName == null) |
| | 826 | | { |
| 0 | 827 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 828 | | } |
| 24 | 829 | | if (vmScaleSetName == null) |
| | 830 | | { |
| 0 | 831 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 832 | | } |
| | 833 | |
|
| 24 | 834 | | using var message = CreateListSkusRequest(resourceGroupName, vmScaleSetName); |
| 24 | 835 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 24 | 836 | | switch (message.Response.Status) |
| | 837 | | { |
| | 838 | | case 200: |
| | 839 | | { |
| 24 | 840 | | VirtualMachineScaleSetListSkusResult value = default; |
| 24 | 841 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 24 | 842 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 843 | | { |
| 0 | 844 | | value = null; |
| | 845 | | } |
| | 846 | | else |
| | 847 | | { |
| 24 | 848 | | value = VirtualMachineScaleSetListSkusResult.DeserializeVirtualMachineScaleSetListSkusResult |
| | 849 | | } |
| 24 | 850 | | return Response.FromValue(value, message.Response); |
| | 851 | | } |
| | 852 | | default: |
| 0 | 853 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 854 | | } |
| 24 | 855 | | } |
| | 856 | |
|
| | 857 | | /// <summary> Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instance |
| | 858 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 859 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 860 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 861 | | public Response<VirtualMachineScaleSetListSkusResult> ListSkus(string resourceGroupName, string vmScaleSetName, |
| | 862 | | { |
| 24 | 863 | | if (resourceGroupName == null) |
| | 864 | | { |
| 0 | 865 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 866 | | } |
| 24 | 867 | | if (vmScaleSetName == null) |
| | 868 | | { |
| 0 | 869 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 870 | | } |
| | 871 | |
|
| 24 | 872 | | using var message = CreateListSkusRequest(resourceGroupName, vmScaleSetName); |
| 24 | 873 | | _pipeline.Send(message, cancellationToken); |
| 24 | 874 | | switch (message.Response.Status) |
| | 875 | | { |
| | 876 | | case 200: |
| | 877 | | { |
| 24 | 878 | | VirtualMachineScaleSetListSkusResult value = default; |
| 24 | 879 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 24 | 880 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 881 | | { |
| 0 | 882 | | value = null; |
| | 883 | | } |
| | 884 | | else |
| | 885 | | { |
| 24 | 886 | | value = VirtualMachineScaleSetListSkusResult.DeserializeVirtualMachineScaleSetListSkusResult |
| | 887 | | } |
| 24 | 888 | | return Response.FromValue(value, message.Response); |
| | 889 | | } |
| | 890 | | default: |
| 0 | 891 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 892 | | } |
| 24 | 893 | | } |
| | 894 | |
|
| | 895 | | internal HttpMessage CreateGetOSUpgradeHistoryRequest(string resourceGroupName, string vmScaleSetName) |
| | 896 | | { |
| 0 | 897 | | var message = _pipeline.CreateMessage(); |
| 0 | 898 | | var request = message.Request; |
| 0 | 899 | | request.Method = RequestMethod.Get; |
| 0 | 900 | | var uri = new RawRequestUriBuilder(); |
| 0 | 901 | | uri.Reset(endpoint); |
| 0 | 902 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 903 | | uri.AppendPath(subscriptionId, true); |
| 0 | 904 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 905 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 906 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 907 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 908 | | uri.AppendPath("/osUpgradeHistory", false); |
| 0 | 909 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 910 | | request.Uri = uri; |
| 0 | 911 | | return message; |
| | 912 | | } |
| | 913 | |
|
| | 914 | | /// <summary> Gets list of OS upgrades on a VM scale set instance. </summary> |
| | 915 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 916 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 917 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 918 | | public async Task<Response<VirtualMachineScaleSetListOSUpgradeHistory>> GetOSUpgradeHistoryAsync(string resource |
| | 919 | | { |
| 0 | 920 | | if (resourceGroupName == null) |
| | 921 | | { |
| 0 | 922 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 923 | | } |
| 0 | 924 | | if (vmScaleSetName == null) |
| | 925 | | { |
| 0 | 926 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 927 | | } |
| | 928 | |
|
| 0 | 929 | | using var message = CreateGetOSUpgradeHistoryRequest(resourceGroupName, vmScaleSetName); |
| 0 | 930 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 931 | | switch (message.Response.Status) |
| | 932 | | { |
| | 933 | | case 200: |
| | 934 | | { |
| 0 | 935 | | VirtualMachineScaleSetListOSUpgradeHistory value = default; |
| 0 | 936 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 937 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 938 | | { |
| 0 | 939 | | value = null; |
| | 940 | | } |
| | 941 | | else |
| | 942 | | { |
| 0 | 943 | | value = VirtualMachineScaleSetListOSUpgradeHistory.DeserializeVirtualMachineScaleSetListOSUp |
| | 944 | | } |
| 0 | 945 | | return Response.FromValue(value, message.Response); |
| | 946 | | } |
| | 947 | | default: |
| 0 | 948 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 949 | | } |
| 0 | 950 | | } |
| | 951 | |
|
| | 952 | | /// <summary> Gets list of OS upgrades on a VM scale set instance. </summary> |
| | 953 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 954 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 955 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 956 | | public Response<VirtualMachineScaleSetListOSUpgradeHistory> GetOSUpgradeHistory(string resourceGroupName, string |
| | 957 | | { |
| 0 | 958 | | if (resourceGroupName == null) |
| | 959 | | { |
| 0 | 960 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 961 | | } |
| 0 | 962 | | if (vmScaleSetName == null) |
| | 963 | | { |
| 0 | 964 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 965 | | } |
| | 966 | |
|
| 0 | 967 | | using var message = CreateGetOSUpgradeHistoryRequest(resourceGroupName, vmScaleSetName); |
| 0 | 968 | | _pipeline.Send(message, cancellationToken); |
| 0 | 969 | | switch (message.Response.Status) |
| | 970 | | { |
| | 971 | | case 200: |
| | 972 | | { |
| 0 | 973 | | VirtualMachineScaleSetListOSUpgradeHistory value = default; |
| 0 | 974 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 975 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 976 | | { |
| 0 | 977 | | value = null; |
| | 978 | | } |
| | 979 | | else |
| | 980 | | { |
| 0 | 981 | | value = VirtualMachineScaleSetListOSUpgradeHistory.DeserializeVirtualMachineScaleSetListOSUp |
| | 982 | | } |
| 0 | 983 | | return Response.FromValue(value, message.Response); |
| | 984 | | } |
| | 985 | | default: |
| 0 | 986 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 987 | | } |
| 0 | 988 | | } |
| | 989 | |
|
| | 990 | | internal HttpMessage CreatePowerOffRequest(string resourceGroupName, string vmScaleSetName, bool? skipShutdown, |
| | 991 | | { |
| 32 | 992 | | var message = _pipeline.CreateMessage(); |
| 32 | 993 | | var request = message.Request; |
| 32 | 994 | | request.Method = RequestMethod.Post; |
| 32 | 995 | | var uri = new RawRequestUriBuilder(); |
| 32 | 996 | | uri.Reset(endpoint); |
| 32 | 997 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 998 | | uri.AppendPath(subscriptionId, true); |
| 32 | 999 | | uri.AppendPath("/resourceGroups/", false); |
| 32 | 1000 | | uri.AppendPath(resourceGroupName, true); |
| 32 | 1001 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 32 | 1002 | | uri.AppendPath(vmScaleSetName, true); |
| 32 | 1003 | | uri.AppendPath("/poweroff", false); |
| 32 | 1004 | | if (skipShutdown != null) |
| | 1005 | | { |
| 8 | 1006 | | uri.AppendQuery("skipShutdown", skipShutdown.Value, true); |
| | 1007 | | } |
| 32 | 1008 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 32 | 1009 | | request.Uri = uri; |
| 32 | 1010 | | request.Headers.Add("Content-Type", "application/json"); |
| 32 | 1011 | | if (vmInstanceIDs != null) |
| | 1012 | | { |
| 8 | 1013 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1014 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 1015 | | request.Content = content; |
| | 1016 | | } |
| 32 | 1017 | | return message; |
| | 1018 | | } |
| | 1019 | |
|
| | 1020 | | /// <summary> Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still att |
| | 1021 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1022 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1023 | | /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi |
| | 1024 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1025 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1026 | | public async Task<Response> PowerOffAsync(string resourceGroupName, string vmScaleSetName, bool? skipShutdown = |
| | 1027 | | { |
| 8 | 1028 | | if (resourceGroupName == null) |
| | 1029 | | { |
| 0 | 1030 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1031 | | } |
| 8 | 1032 | | if (vmScaleSetName == null) |
| | 1033 | | { |
| 0 | 1034 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1035 | | } |
| | 1036 | |
|
| 8 | 1037 | | using var message = CreatePowerOffRequest(resourceGroupName, vmScaleSetName, skipShutdown, vmInstanceIDs); |
| 8 | 1038 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 1039 | | switch (message.Response.Status) |
| | 1040 | | { |
| | 1041 | | case 200: |
| | 1042 | | case 202: |
| 8 | 1043 | | return message.Response; |
| | 1044 | | default: |
| 0 | 1045 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1046 | | } |
| 8 | 1047 | | } |
| | 1048 | |
|
| | 1049 | | /// <summary> Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still att |
| | 1050 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1051 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1052 | | /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi |
| | 1053 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1054 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1055 | | public Response PowerOff(string resourceGroupName, string vmScaleSetName, bool? skipShutdown = null, VirtualMach |
| | 1056 | | { |
| 8 | 1057 | | if (resourceGroupName == null) |
| | 1058 | | { |
| 0 | 1059 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1060 | | } |
| 8 | 1061 | | if (vmScaleSetName == null) |
| | 1062 | | { |
| 0 | 1063 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1064 | | } |
| | 1065 | |
|
| 8 | 1066 | | using var message = CreatePowerOffRequest(resourceGroupName, vmScaleSetName, skipShutdown, vmInstanceIDs); |
| 8 | 1067 | | _pipeline.Send(message, cancellationToken); |
| 8 | 1068 | | switch (message.Response.Status) |
| | 1069 | | { |
| | 1070 | | case 200: |
| | 1071 | | case 202: |
| 8 | 1072 | | return message.Response; |
| | 1073 | | default: |
| 0 | 1074 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1075 | | } |
| 8 | 1076 | | } |
| | 1077 | |
|
| | 1078 | | internal HttpMessage CreateRestartRequest(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSe |
| | 1079 | | { |
| 24 | 1080 | | var message = _pipeline.CreateMessage(); |
| 24 | 1081 | | var request = message.Request; |
| 24 | 1082 | | request.Method = RequestMethod.Post; |
| 24 | 1083 | | var uri = new RawRequestUriBuilder(); |
| 24 | 1084 | | uri.Reset(endpoint); |
| 24 | 1085 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 1086 | | uri.AppendPath(subscriptionId, true); |
| 24 | 1087 | | uri.AppendPath("/resourceGroups/", false); |
| 24 | 1088 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 1089 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 24 | 1090 | | uri.AppendPath(vmScaleSetName, true); |
| 24 | 1091 | | uri.AppendPath("/restart", false); |
| 24 | 1092 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 24 | 1093 | | request.Uri = uri; |
| 24 | 1094 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 1095 | | if (vmInstanceIDs != null) |
| | 1096 | | { |
| 8 | 1097 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1098 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 1099 | | request.Content = content; |
| | 1100 | | } |
| 24 | 1101 | | return message; |
| | 1102 | | } |
| | 1103 | |
|
| | 1104 | | /// <summary> Restarts one or more virtual machines in a VM scale set. </summary> |
| | 1105 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1106 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1107 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1108 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1109 | | public async Task<Response> RestartAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSet |
| | 1110 | | { |
| 6 | 1111 | | if (resourceGroupName == null) |
| | 1112 | | { |
| 0 | 1113 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1114 | | } |
| 6 | 1115 | | if (vmScaleSetName == null) |
| | 1116 | | { |
| 0 | 1117 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1118 | | } |
| | 1119 | |
|
| 6 | 1120 | | using var message = CreateRestartRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 6 | 1121 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 1122 | | switch (message.Response.Status) |
| | 1123 | | { |
| | 1124 | | case 200: |
| | 1125 | | case 202: |
| 6 | 1126 | | return message.Response; |
| | 1127 | | default: |
| 0 | 1128 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1129 | | } |
| 6 | 1130 | | } |
| | 1131 | |
|
| | 1132 | | /// <summary> Restarts one or more virtual machines in a VM scale set. </summary> |
| | 1133 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1134 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1135 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1136 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1137 | | public Response Restart(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInstanceIDs vmI |
| | 1138 | | { |
| 6 | 1139 | | if (resourceGroupName == null) |
| | 1140 | | { |
| 0 | 1141 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1142 | | } |
| 6 | 1143 | | if (vmScaleSetName == null) |
| | 1144 | | { |
| 0 | 1145 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1146 | | } |
| | 1147 | |
|
| 6 | 1148 | | using var message = CreateRestartRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 6 | 1149 | | _pipeline.Send(message, cancellationToken); |
| 6 | 1150 | | switch (message.Response.Status) |
| | 1151 | | { |
| | 1152 | | case 200: |
| | 1153 | | case 202: |
| 6 | 1154 | | return message.Response; |
| | 1155 | | default: |
| 0 | 1156 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1157 | | } |
| 6 | 1158 | | } |
| | 1159 | |
|
| | 1160 | | internal HttpMessage CreateStartRequest(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetV |
| | 1161 | | { |
| 32 | 1162 | | var message = _pipeline.CreateMessage(); |
| 32 | 1163 | | var request = message.Request; |
| 32 | 1164 | | request.Method = RequestMethod.Post; |
| 32 | 1165 | | var uri = new RawRequestUriBuilder(); |
| 32 | 1166 | | uri.Reset(endpoint); |
| 32 | 1167 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 1168 | | uri.AppendPath(subscriptionId, true); |
| 32 | 1169 | | uri.AppendPath("/resourceGroups/", false); |
| 32 | 1170 | | uri.AppendPath(resourceGroupName, true); |
| 32 | 1171 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 32 | 1172 | | uri.AppendPath(vmScaleSetName, true); |
| 32 | 1173 | | uri.AppendPath("/start", false); |
| 32 | 1174 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 32 | 1175 | | request.Uri = uri; |
| 32 | 1176 | | request.Headers.Add("Content-Type", "application/json"); |
| 32 | 1177 | | if (vmInstanceIDs != null) |
| | 1178 | | { |
| 8 | 1179 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1180 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 1181 | | request.Content = content; |
| | 1182 | | } |
| 32 | 1183 | | return message; |
| | 1184 | | } |
| | 1185 | |
|
| | 1186 | | /// <summary> Starts one or more virtual machines in a VM scale set. </summary> |
| | 1187 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1188 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1189 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1190 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1191 | | public async Task<Response> StartAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVM |
| | 1192 | | { |
| 8 | 1193 | | if (resourceGroupName == null) |
| | 1194 | | { |
| 0 | 1195 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1196 | | } |
| 8 | 1197 | | if (vmScaleSetName == null) |
| | 1198 | | { |
| 0 | 1199 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1200 | | } |
| | 1201 | |
|
| 8 | 1202 | | using var message = CreateStartRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 8 | 1203 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 1204 | | switch (message.Response.Status) |
| | 1205 | | { |
| | 1206 | | case 200: |
| | 1207 | | case 202: |
| 8 | 1208 | | return message.Response; |
| | 1209 | | default: |
| 0 | 1210 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1211 | | } |
| 8 | 1212 | | } |
| | 1213 | |
|
| | 1214 | | /// <summary> Starts one or more virtual machines in a VM scale set. </summary> |
| | 1215 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1216 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1217 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1218 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1219 | | public Response Start(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInstanceIDs vmIns |
| | 1220 | | { |
| 8 | 1221 | | if (resourceGroupName == null) |
| | 1222 | | { |
| 0 | 1223 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1224 | | } |
| 8 | 1225 | | if (vmScaleSetName == null) |
| | 1226 | | { |
| 0 | 1227 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1228 | | } |
| | 1229 | |
|
| 8 | 1230 | | using var message = CreateStartRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 8 | 1231 | | _pipeline.Send(message, cancellationToken); |
| 8 | 1232 | | switch (message.Response.Status) |
| | 1233 | | { |
| | 1234 | | case 200: |
| | 1235 | | case 202: |
| 8 | 1236 | | return message.Response; |
| | 1237 | | default: |
| 0 | 1238 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1239 | | } |
| 8 | 1240 | | } |
| | 1241 | |
|
| | 1242 | | internal HttpMessage CreateRedeployRequest(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleS |
| | 1243 | | { |
| 16 | 1244 | | var message = _pipeline.CreateMessage(); |
| 16 | 1245 | | var request = message.Request; |
| 16 | 1246 | | request.Method = RequestMethod.Post; |
| 16 | 1247 | | var uri = new RawRequestUriBuilder(); |
| 16 | 1248 | | uri.Reset(endpoint); |
| 16 | 1249 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 1250 | | uri.AppendPath(subscriptionId, true); |
| 16 | 1251 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 1252 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 1253 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 1254 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 1255 | | uri.AppendPath("/redeploy", false); |
| 16 | 1256 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 1257 | | request.Uri = uri; |
| 16 | 1258 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 1259 | | if (vmInstanceIDs != null) |
| | 1260 | | { |
| 8 | 1261 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1262 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 1263 | | request.Content = content; |
| | 1264 | | } |
| 16 | 1265 | | return message; |
| | 1266 | | } |
| | 1267 | |
|
| | 1268 | | /// <summary> Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, an |
| | 1269 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1270 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1271 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1273 | | public async Task<Response> RedeployAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSe |
| | 1274 | | { |
| 4 | 1275 | | if (resourceGroupName == null) |
| | 1276 | | { |
| 0 | 1277 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1278 | | } |
| 4 | 1279 | | if (vmScaleSetName == null) |
| | 1280 | | { |
| 0 | 1281 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1282 | | } |
| | 1283 | |
|
| 4 | 1284 | | using var message = CreateRedeployRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 4 | 1285 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1286 | | switch (message.Response.Status) |
| | 1287 | | { |
| | 1288 | | case 200: |
| | 1289 | | case 202: |
| 4 | 1290 | | return message.Response; |
| | 1291 | | default: |
| 0 | 1292 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1293 | | } |
| 4 | 1294 | | } |
| | 1295 | |
|
| | 1296 | | /// <summary> Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, an |
| | 1297 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1298 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1299 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1300 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1301 | | public Response Redeploy(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInstanceIDs vm |
| | 1302 | | { |
| 4 | 1303 | | if (resourceGroupName == null) |
| | 1304 | | { |
| 0 | 1305 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1306 | | } |
| 4 | 1307 | | if (vmScaleSetName == null) |
| | 1308 | | { |
| 0 | 1309 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1310 | | } |
| | 1311 | |
|
| 4 | 1312 | | using var message = CreateRedeployRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 4 | 1313 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1314 | | switch (message.Response.Status) |
| | 1315 | | { |
| | 1316 | | case 200: |
| | 1317 | | case 202: |
| 4 | 1318 | | return message.Response; |
| | 1319 | | default: |
| 0 | 1320 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1321 | | } |
| 4 | 1322 | | } |
| | 1323 | |
|
| | 1324 | | internal HttpMessage CreatePerformMaintenanceRequest(string resourceGroupName, string vmScaleSetName, VirtualMac |
| | 1325 | | { |
| 8 | 1326 | | var message = _pipeline.CreateMessage(); |
| 8 | 1327 | | var request = message.Request; |
| 8 | 1328 | | request.Method = RequestMethod.Post; |
| 8 | 1329 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1330 | | uri.Reset(endpoint); |
| 8 | 1331 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 1332 | | uri.AppendPath(subscriptionId, true); |
| 8 | 1333 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 1334 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 1335 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 8 | 1336 | | uri.AppendPath(vmScaleSetName, true); |
| 8 | 1337 | | uri.AppendPath("/performMaintenance", false); |
| 8 | 1338 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 1339 | | request.Uri = uri; |
| 8 | 1340 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 1341 | | if (vmInstanceIDs != null) |
| | 1342 | | { |
| 4 | 1343 | | var content = new Utf8JsonRequestContent(); |
| 4 | 1344 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 4 | 1345 | | request.Content = content; |
| | 1346 | | } |
| 8 | 1347 | | return message; |
| | 1348 | | } |
| | 1349 | |
|
| | 1350 | | /// <summary> Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances whic |
| | 1351 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1352 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1353 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1354 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1355 | | public async Task<Response> PerformMaintenanceAsync(string resourceGroupName, string vmScaleSetName, VirtualMach |
| | 1356 | | { |
| 4 | 1357 | | if (resourceGroupName == null) |
| | 1358 | | { |
| 0 | 1359 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1360 | | } |
| 4 | 1361 | | if (vmScaleSetName == null) |
| | 1362 | | { |
| 0 | 1363 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1364 | | } |
| | 1365 | |
|
| 4 | 1366 | | using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 4 | 1367 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1368 | | switch (message.Response.Status) |
| | 1369 | | { |
| | 1370 | | case 200: |
| | 1371 | | case 202: |
| 0 | 1372 | | return message.Response; |
| | 1373 | | default: |
| 4 | 1374 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1375 | | } |
| 0 | 1376 | | } |
| | 1377 | |
|
| | 1378 | | /// <summary> Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances whic |
| | 1379 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1380 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1381 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1382 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1383 | | public Response PerformMaintenance(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInst |
| | 1384 | | { |
| 4 | 1385 | | if (resourceGroupName == null) |
| | 1386 | | { |
| 0 | 1387 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1388 | | } |
| 4 | 1389 | | if (vmScaleSetName == null) |
| | 1390 | | { |
| 0 | 1391 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1392 | | } |
| | 1393 | |
|
| 4 | 1394 | | using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 4 | 1395 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1396 | | switch (message.Response.Status) |
| | 1397 | | { |
| | 1398 | | case 200: |
| | 1399 | | case 202: |
| 0 | 1400 | | return message.Response; |
| | 1401 | | default: |
| 4 | 1402 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1403 | | } |
| 0 | 1404 | | } |
| | 1405 | |
|
| | 1406 | | internal HttpMessage CreateUpdateInstancesRequest(string resourceGroupName, string vmScaleSetName, VirtualMachin |
| | 1407 | | { |
| 8 | 1408 | | var message = _pipeline.CreateMessage(); |
| 8 | 1409 | | var request = message.Request; |
| 8 | 1410 | | request.Method = RequestMethod.Post; |
| 8 | 1411 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1412 | | uri.Reset(endpoint); |
| 8 | 1413 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 1414 | | uri.AppendPath(subscriptionId, true); |
| 8 | 1415 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 1416 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 1417 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 8 | 1418 | | uri.AppendPath(vmScaleSetName, true); |
| 8 | 1419 | | uri.AppendPath("/manualupgrade", false); |
| 8 | 1420 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 8 | 1421 | | request.Uri = uri; |
| 8 | 1422 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 1423 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1424 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 1425 | | request.Content = content; |
| 8 | 1426 | | return message; |
| | 1427 | | } |
| | 1428 | |
|
| | 1429 | | /// <summary> Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. </summary> |
| | 1430 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1431 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1432 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1433 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1434 | | public async Task<Response> UpdateInstancesAsync(string resourceGroupName, string vmScaleSetName, VirtualMachine |
| | 1435 | | { |
| 2 | 1436 | | if (resourceGroupName == null) |
| | 1437 | | { |
| 0 | 1438 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1439 | | } |
| 2 | 1440 | | if (vmScaleSetName == null) |
| | 1441 | | { |
| 0 | 1442 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1443 | | } |
| 2 | 1444 | | if (vmInstanceIDs == null) |
| | 1445 | | { |
| 0 | 1446 | | throw new ArgumentNullException(nameof(vmInstanceIDs)); |
| | 1447 | | } |
| | 1448 | |
|
| 2 | 1449 | | using var message = CreateUpdateInstancesRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 2 | 1450 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1451 | | switch (message.Response.Status) |
| | 1452 | | { |
| | 1453 | | case 200: |
| | 1454 | | case 202: |
| 2 | 1455 | | return message.Response; |
| | 1456 | | default: |
| 0 | 1457 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1458 | | } |
| 2 | 1459 | | } |
| | 1460 | |
|
| | 1461 | | /// <summary> Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. </summary> |
| | 1462 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1463 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1464 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1465 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1466 | | public Response UpdateInstances(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInstanc |
| | 1467 | | { |
| 2 | 1468 | | if (resourceGroupName == null) |
| | 1469 | | { |
| 0 | 1470 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1471 | | } |
| 2 | 1472 | | if (vmScaleSetName == null) |
| | 1473 | | { |
| 0 | 1474 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1475 | | } |
| 2 | 1476 | | if (vmInstanceIDs == null) |
| | 1477 | | { |
| 0 | 1478 | | throw new ArgumentNullException(nameof(vmInstanceIDs)); |
| | 1479 | | } |
| | 1480 | |
|
| 2 | 1481 | | using var message = CreateUpdateInstancesRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 2 | 1482 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1483 | | switch (message.Response.Status) |
| | 1484 | | { |
| | 1485 | | case 200: |
| | 1486 | | case 202: |
| 2 | 1487 | | return message.Response; |
| | 1488 | | default: |
| 0 | 1489 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1490 | | } |
| 2 | 1491 | | } |
| | 1492 | |
|
| | 1493 | | internal HttpMessage CreateReimageRequest(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSe |
| | 1494 | | { |
| 24 | 1495 | | var message = _pipeline.CreateMessage(); |
| 24 | 1496 | | var request = message.Request; |
| 24 | 1497 | | request.Method = RequestMethod.Post; |
| 24 | 1498 | | var uri = new RawRequestUriBuilder(); |
| 24 | 1499 | | uri.Reset(endpoint); |
| 24 | 1500 | | uri.AppendPath("/subscriptions/", false); |
| 24 | 1501 | | uri.AppendPath(subscriptionId, true); |
| 24 | 1502 | | uri.AppendPath("/resourceGroups/", false); |
| 24 | 1503 | | uri.AppendPath(resourceGroupName, true); |
| 24 | 1504 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 24 | 1505 | | uri.AppendPath(vmScaleSetName, true); |
| 24 | 1506 | | uri.AppendPath("/reimage", false); |
| 24 | 1507 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 24 | 1508 | | request.Uri = uri; |
| 24 | 1509 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 1510 | | if (vmScaleSetReimageInput != null) |
| | 1511 | | { |
| 8 | 1512 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1513 | | content.JsonWriter.WriteObjectValue(vmScaleSetReimageInput); |
| 8 | 1514 | | request.Content = content; |
| | 1515 | | } |
| 24 | 1516 | | return message; |
| | 1517 | | } |
| | 1518 | |
|
| | 1519 | | /// <summary> Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which don&a |
| | 1520 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1521 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1522 | | /// <param name="vmScaleSetReimageInput"> Parameters for Reimaging VM ScaleSet. </param> |
| | 1523 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1524 | | public async Task<Response> ReimageAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSet |
| | 1525 | | { |
| 6 | 1526 | | if (resourceGroupName == null) |
| | 1527 | | { |
| 0 | 1528 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1529 | | } |
| 6 | 1530 | | if (vmScaleSetName == null) |
| | 1531 | | { |
| 0 | 1532 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1533 | | } |
| | 1534 | |
|
| 6 | 1535 | | using var message = CreateReimageRequest(resourceGroupName, vmScaleSetName, vmScaleSetReimageInput); |
| 6 | 1536 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 1537 | | switch (message.Response.Status) |
| | 1538 | | { |
| | 1539 | | case 200: |
| | 1540 | | case 202: |
| 6 | 1541 | | return message.Response; |
| | 1542 | | default: |
| 0 | 1543 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1544 | | } |
| 6 | 1545 | | } |
| | 1546 | |
|
| | 1547 | | /// <summary> Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which don&a |
| | 1548 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1549 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1550 | | /// <param name="vmScaleSetReimageInput"> Parameters for Reimaging VM ScaleSet. </param> |
| | 1551 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1552 | | public Response Reimage(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetReimageParameters |
| | 1553 | | { |
| 6 | 1554 | | if (resourceGroupName == null) |
| | 1555 | | { |
| 0 | 1556 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1557 | | } |
| 6 | 1558 | | if (vmScaleSetName == null) |
| | 1559 | | { |
| 0 | 1560 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1561 | | } |
| | 1562 | |
|
| 6 | 1563 | | using var message = CreateReimageRequest(resourceGroupName, vmScaleSetName, vmScaleSetReimageInput); |
| 6 | 1564 | | _pipeline.Send(message, cancellationToken); |
| 6 | 1565 | | switch (message.Response.Status) |
| | 1566 | | { |
| | 1567 | | case 200: |
| | 1568 | | case 202: |
| 6 | 1569 | | return message.Response; |
| | 1570 | | default: |
| 0 | 1571 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1572 | | } |
| 6 | 1573 | | } |
| | 1574 | |
|
| | 1575 | | internal HttpMessage CreateReimageAllRequest(string resourceGroupName, string vmScaleSetName, VirtualMachineScal |
| | 1576 | | { |
| 16 | 1577 | | var message = _pipeline.CreateMessage(); |
| 16 | 1578 | | var request = message.Request; |
| 16 | 1579 | | request.Method = RequestMethod.Post; |
| 16 | 1580 | | var uri = new RawRequestUriBuilder(); |
| 16 | 1581 | | uri.Reset(endpoint); |
| 16 | 1582 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 1583 | | uri.AppendPath(subscriptionId, true); |
| 16 | 1584 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 1585 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 1586 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 1587 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 1588 | | uri.AppendPath("/reimageall", false); |
| 16 | 1589 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 1590 | | request.Uri = uri; |
| 16 | 1591 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 1592 | | if (vmInstanceIDs != null) |
| | 1593 | | { |
| 8 | 1594 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1595 | | content.JsonWriter.WriteObjectValue(vmInstanceIDs); |
| 8 | 1596 | | request.Content = content; |
| | 1597 | | } |
| 16 | 1598 | | return message; |
| | 1599 | | } |
| | 1600 | |
|
| | 1601 | | /// <summary> Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This op |
| | 1602 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1603 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1604 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1605 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1606 | | public async Task<Response> ReimageAllAsync(string resourceGroupName, string vmScaleSetName, VirtualMachineScale |
| | 1607 | | { |
| 4 | 1608 | | if (resourceGroupName == null) |
| | 1609 | | { |
| 0 | 1610 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1611 | | } |
| 4 | 1612 | | if (vmScaleSetName == null) |
| | 1613 | | { |
| 0 | 1614 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1615 | | } |
| | 1616 | |
|
| 4 | 1617 | | using var message = CreateReimageAllRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 4 | 1618 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1619 | | switch (message.Response.Status) |
| | 1620 | | { |
| | 1621 | | case 200: |
| | 1622 | | case 202: |
| 4 | 1623 | | return message.Response; |
| | 1624 | | default: |
| 0 | 1625 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1626 | | } |
| 4 | 1627 | | } |
| | 1628 | |
|
| | 1629 | | /// <summary> Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This op |
| | 1630 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1631 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1632 | | /// <param name="vmInstanceIDs"> A list of virtual machine instance IDs from the VM scale set. </param> |
| | 1633 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1634 | | public Response ReimageAll(string resourceGroupName, string vmScaleSetName, VirtualMachineScaleSetVMInstanceIDs |
| | 1635 | | { |
| 4 | 1636 | | if (resourceGroupName == null) |
| | 1637 | | { |
| 0 | 1638 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1639 | | } |
| 4 | 1640 | | if (vmScaleSetName == null) |
| | 1641 | | { |
| 0 | 1642 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1643 | | } |
| | 1644 | |
|
| 4 | 1645 | | using var message = CreateReimageAllRequest(resourceGroupName, vmScaleSetName, vmInstanceIDs); |
| 4 | 1646 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1647 | | switch (message.Response.Status) |
| | 1648 | | { |
| | 1649 | | case 200: |
| | 1650 | | case 202: |
| 4 | 1651 | | return message.Response; |
| | 1652 | | default: |
| 0 | 1653 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1654 | | } |
| 4 | 1655 | | } |
| | 1656 | |
|
| | 1657 | | internal HttpMessage CreateForceRecoveryServiceFabricPlatformUpdateDomainWalkRequest(string resourceGroupName, s |
| | 1658 | | { |
| 0 | 1659 | | var message = _pipeline.CreateMessage(); |
| 0 | 1660 | | var request = message.Request; |
| 0 | 1661 | | request.Method = RequestMethod.Post; |
| 0 | 1662 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1663 | | uri.Reset(endpoint); |
| 0 | 1664 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1665 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1666 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1667 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1668 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 1669 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 1670 | | uri.AppendPath("/forceRecoveryServiceFabricPlatformUpdateDomainWalk", false); |
| 0 | 1671 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 1672 | | uri.AppendQuery("platformUpdateDomain", platformUpdateDomain, true); |
| 0 | 1673 | | request.Uri = uri; |
| 0 | 1674 | | return message; |
| | 1675 | | } |
| | 1676 | |
|
| | 1677 | | /// <summary> Manual platform update domain walk to update virtual machines in a service fabric virtual machine |
| | 1678 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1679 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1680 | | /// <param name="platformUpdateDomain"> The platform update domain for which a manual recovery walk is requested |
| | 1681 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1682 | | public async Task<Response<RecoveryWalkResponse>> ForceRecoveryServiceFabricPlatformUpdateDomainWalkAsync(string |
| | 1683 | | { |
| 0 | 1684 | | if (resourceGroupName == null) |
| | 1685 | | { |
| 0 | 1686 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1687 | | } |
| 0 | 1688 | | if (vmScaleSetName == null) |
| | 1689 | | { |
| 0 | 1690 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1691 | | } |
| | 1692 | |
|
| 0 | 1693 | | using var message = CreateForceRecoveryServiceFabricPlatformUpdateDomainWalkRequest(resourceGroupName, vmSca |
| 0 | 1694 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1695 | | switch (message.Response.Status) |
| | 1696 | | { |
| | 1697 | | case 200: |
| | 1698 | | { |
| 0 | 1699 | | RecoveryWalkResponse value = default; |
| 0 | 1700 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1701 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1702 | | { |
| 0 | 1703 | | value = null; |
| | 1704 | | } |
| | 1705 | | else |
| | 1706 | | { |
| 0 | 1707 | | value = RecoveryWalkResponse.DeserializeRecoveryWalkResponse(document.RootElement); |
| | 1708 | | } |
| 0 | 1709 | | return Response.FromValue(value, message.Response); |
| | 1710 | | } |
| | 1711 | | default: |
| 0 | 1712 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1713 | | } |
| 0 | 1714 | | } |
| | 1715 | |
|
| | 1716 | | /// <summary> Manual platform update domain walk to update virtual machines in a service fabric virtual machine |
| | 1717 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1718 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 1719 | | /// <param name="platformUpdateDomain"> The platform update domain for which a manual recovery walk is requested |
| | 1720 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1721 | | public Response<RecoveryWalkResponse> ForceRecoveryServiceFabricPlatformUpdateDomainWalk(string resourceGroupNam |
| | 1722 | | { |
| 0 | 1723 | | if (resourceGroupName == null) |
| | 1724 | | { |
| 0 | 1725 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1726 | | } |
| 0 | 1727 | | if (vmScaleSetName == null) |
| | 1728 | | { |
| 0 | 1729 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1730 | | } |
| | 1731 | |
|
| 0 | 1732 | | using var message = CreateForceRecoveryServiceFabricPlatformUpdateDomainWalkRequest(resourceGroupName, vmSca |
| 0 | 1733 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1734 | | switch (message.Response.Status) |
| | 1735 | | { |
| | 1736 | | case 200: |
| | 1737 | | { |
| 0 | 1738 | | RecoveryWalkResponse value = default; |
| 0 | 1739 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1740 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1741 | | { |
| 0 | 1742 | | value = null; |
| | 1743 | | } |
| | 1744 | | else |
| | 1745 | | { |
| 0 | 1746 | | value = RecoveryWalkResponse.DeserializeRecoveryWalkResponse(document.RootElement); |
| | 1747 | | } |
| 0 | 1748 | | return Response.FromValue(value, message.Response); |
| | 1749 | | } |
| | 1750 | | default: |
| 0 | 1751 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1752 | | } |
| 0 | 1753 | | } |
| | 1754 | |
|
| | 1755 | | internal HttpMessage CreateConvertToSinglePlacementGroupRequest(string resourceGroupName, string vmScaleSetName, |
| | 1756 | | { |
| 0 | 1757 | | var message = _pipeline.CreateMessage(); |
| 0 | 1758 | | var request = message.Request; |
| 0 | 1759 | | request.Method = RequestMethod.Post; |
| 0 | 1760 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1761 | | uri.Reset(endpoint); |
| 0 | 1762 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1763 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1764 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1765 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1766 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 0 | 1767 | | uri.AppendPath(vmScaleSetName, true); |
| 0 | 1768 | | uri.AppendPath("/convertToSinglePlacementGroup", false); |
| 0 | 1769 | | request.Uri = uri; |
| 0 | 1770 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1771 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1772 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1773 | | request.Content = content; |
| 0 | 1774 | | return message; |
| | 1775 | | } |
| | 1776 | |
|
| | 1777 | | /// <summary> Converts SinglePlacementGroup property to false for a existing virtual machine scale set. </summar |
| | 1778 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1779 | | /// <param name="vmScaleSetName"> The name of the virtual machine scale set to create or update. </param> |
| | 1780 | | /// <param name="parameters"> The input object for ConvertToSinglePlacementGroup API. </param> |
| | 1781 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1782 | | public async Task<Response> ConvertToSinglePlacementGroupAsync(string resourceGroupName, string vmScaleSetName, |
| | 1783 | | { |
| 0 | 1784 | | if (resourceGroupName == null) |
| | 1785 | | { |
| 0 | 1786 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1787 | | } |
| 0 | 1788 | | if (vmScaleSetName == null) |
| | 1789 | | { |
| 0 | 1790 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1791 | | } |
| 0 | 1792 | | if (parameters == null) |
| | 1793 | | { |
| 0 | 1794 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1795 | | } |
| | 1796 | |
|
| 0 | 1797 | | using var message = CreateConvertToSinglePlacementGroupRequest(resourceGroupName, vmScaleSetName, parameters |
| 0 | 1798 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1799 | | switch (message.Response.Status) |
| | 1800 | | { |
| | 1801 | | case 200: |
| 0 | 1802 | | return message.Response; |
| | 1803 | | default: |
| 0 | 1804 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1805 | | } |
| 0 | 1806 | | } |
| | 1807 | |
|
| | 1808 | | /// <summary> Converts SinglePlacementGroup property to false for a existing virtual machine scale set. </summar |
| | 1809 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1810 | | /// <param name="vmScaleSetName"> The name of the virtual machine scale set to create or update. </param> |
| | 1811 | | /// <param name="parameters"> The input object for ConvertToSinglePlacementGroup API. </param> |
| | 1812 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1813 | | public Response ConvertToSinglePlacementGroup(string resourceGroupName, string vmScaleSetName, VMScaleSetConvert |
| | 1814 | | { |
| 0 | 1815 | | if (resourceGroupName == null) |
| | 1816 | | { |
| 0 | 1817 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1818 | | } |
| 0 | 1819 | | if (vmScaleSetName == null) |
| | 1820 | | { |
| 0 | 1821 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1822 | | } |
| 0 | 1823 | | if (parameters == null) |
| | 1824 | | { |
| 0 | 1825 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1826 | | } |
| | 1827 | |
|
| 0 | 1828 | | using var message = CreateConvertToSinglePlacementGroupRequest(resourceGroupName, vmScaleSetName, parameters |
| 0 | 1829 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1830 | | switch (message.Response.Status) |
| | 1831 | | { |
| | 1832 | | case 200: |
| 0 | 1833 | | return message.Response; |
| | 1834 | | default: |
| 0 | 1835 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1836 | | } |
| 0 | 1837 | | } |
| | 1838 | |
|
| | 1839 | | internal HttpMessage CreateSetOrchestrationServiceStateRequest(string resourceGroupName, string vmScaleSetName, |
| | 1840 | | { |
| 16 | 1841 | | var message = _pipeline.CreateMessage(); |
| 16 | 1842 | | var request = message.Request; |
| 16 | 1843 | | request.Method = RequestMethod.Post; |
| 16 | 1844 | | var uri = new RawRequestUriBuilder(); |
| 16 | 1845 | | uri.Reset(endpoint); |
| 16 | 1846 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 1847 | | uri.AppendPath(subscriptionId, true); |
| 16 | 1848 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 1849 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 1850 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); |
| 16 | 1851 | | uri.AppendPath(vmScaleSetName, true); |
| 16 | 1852 | | uri.AppendPath("/setOrchestrationServiceState", false); |
| 16 | 1853 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 16 | 1854 | | request.Uri = uri; |
| 16 | 1855 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 1856 | | var content = new Utf8JsonRequestContent(); |
| 16 | 1857 | | content.JsonWriter.WriteObjectValue(parameters); |
| 16 | 1858 | | request.Content = content; |
| 16 | 1859 | | return message; |
| | 1860 | | } |
| | 1861 | |
|
| | 1862 | | /// <summary> Changes ServiceState property for a given service. </summary> |
| | 1863 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1864 | | /// <param name="vmScaleSetName"> The name of the virtual machine scale set to create or update. </param> |
| | 1865 | | /// <param name="parameters"> The input object for SetOrchestrationServiceState API. </param> |
| | 1866 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1867 | | public async Task<Response> SetOrchestrationServiceStateAsync(string resourceGroupName, string vmScaleSetName, O |
| | 1868 | | { |
| 4 | 1869 | | if (resourceGroupName == null) |
| | 1870 | | { |
| 0 | 1871 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1872 | | } |
| 4 | 1873 | | if (vmScaleSetName == null) |
| | 1874 | | { |
| 0 | 1875 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1876 | | } |
| 4 | 1877 | | if (parameters == null) |
| | 1878 | | { |
| 0 | 1879 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1880 | | } |
| | 1881 | |
|
| 4 | 1882 | | using var message = CreateSetOrchestrationServiceStateRequest(resourceGroupName, vmScaleSetName, parameters) |
| 4 | 1883 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1884 | | switch (message.Response.Status) |
| | 1885 | | { |
| | 1886 | | case 200: |
| | 1887 | | case 202: |
| 4 | 1888 | | return message.Response; |
| | 1889 | | default: |
| 0 | 1890 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1891 | | } |
| 4 | 1892 | | } |
| | 1893 | |
|
| | 1894 | | /// <summary> Changes ServiceState property for a given service. </summary> |
| | 1895 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1896 | | /// <param name="vmScaleSetName"> The name of the virtual machine scale set to create or update. </param> |
| | 1897 | | /// <param name="parameters"> The input object for SetOrchestrationServiceState API. </param> |
| | 1898 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1899 | | public Response SetOrchestrationServiceState(string resourceGroupName, string vmScaleSetName, OrchestrationServi |
| | 1900 | | { |
| 4 | 1901 | | if (resourceGroupName == null) |
| | 1902 | | { |
| 0 | 1903 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1904 | | } |
| 4 | 1905 | | if (vmScaleSetName == null) |
| | 1906 | | { |
| 0 | 1907 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 1908 | | } |
| 4 | 1909 | | if (parameters == null) |
| | 1910 | | { |
| 0 | 1911 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1912 | | } |
| | 1913 | |
|
| 4 | 1914 | | using var message = CreateSetOrchestrationServiceStateRequest(resourceGroupName, vmScaleSetName, parameters) |
| 4 | 1915 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1916 | | switch (message.Response.Status) |
| | 1917 | | { |
| | 1918 | | case 200: |
| | 1919 | | case 202: |
| 4 | 1920 | | return message.Response; |
| | 1921 | | default: |
| 0 | 1922 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1923 | | } |
| 4 | 1924 | | } |
| | 1925 | |
|
| | 1926 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName) |
| | 1927 | | { |
| 0 | 1928 | | var message = _pipeline.CreateMessage(); |
| 0 | 1929 | | var request = message.Request; |
| 0 | 1930 | | request.Method = RequestMethod.Get; |
| 0 | 1931 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1932 | | uri.Reset(endpoint); |
| 0 | 1933 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1934 | | request.Uri = uri; |
| 0 | 1935 | | return message; |
| | 1936 | | } |
| | 1937 | |
|
| | 1938 | | /// <summary> Gets a list of all VM scale sets under a resource group. </summary> |
| | 1939 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1940 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1941 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1942 | | public async Task<Response<VirtualMachineScaleSetListResult>> ListNextPageAsync(string nextLink, string resource |
| | 1943 | | { |
| 0 | 1944 | | if (nextLink == null) |
| | 1945 | | { |
| 0 | 1946 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1947 | | } |
| 0 | 1948 | | if (resourceGroupName == null) |
| | 1949 | | { |
| 0 | 1950 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1951 | | } |
| | 1952 | |
|
| 0 | 1953 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName); |
| 0 | 1954 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1955 | | switch (message.Response.Status) |
| | 1956 | | { |
| | 1957 | | case 200: |
| | 1958 | | { |
| 0 | 1959 | | VirtualMachineScaleSetListResult value = default; |
| 0 | 1960 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1961 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1962 | | { |
| 0 | 1963 | | value = null; |
| | 1964 | | } |
| | 1965 | | else |
| | 1966 | | { |
| 0 | 1967 | | value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(documen |
| | 1968 | | } |
| 0 | 1969 | | return Response.FromValue(value, message.Response); |
| | 1970 | | } |
| | 1971 | | default: |
| 0 | 1972 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1973 | | } |
| 0 | 1974 | | } |
| | 1975 | |
|
| | 1976 | | /// <summary> Gets a list of all VM scale sets under a resource group. </summary> |
| | 1977 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1978 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1979 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1980 | | public Response<VirtualMachineScaleSetListResult> ListNextPage(string nextLink, string resourceGroupName, Cancel |
| | 1981 | | { |
| 0 | 1982 | | if (nextLink == null) |
| | 1983 | | { |
| 0 | 1984 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1985 | | } |
| 0 | 1986 | | if (resourceGroupName == null) |
| | 1987 | | { |
| 0 | 1988 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1989 | | } |
| | 1990 | |
|
| 0 | 1991 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName); |
| 0 | 1992 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1993 | | switch (message.Response.Status) |
| | 1994 | | { |
| | 1995 | | case 200: |
| | 1996 | | { |
| 0 | 1997 | | VirtualMachineScaleSetListResult value = default; |
| 0 | 1998 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1999 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2000 | | { |
| 0 | 2001 | | value = null; |
| | 2002 | | } |
| | 2003 | | else |
| | 2004 | | { |
| 0 | 2005 | | value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(documen |
| | 2006 | | } |
| 0 | 2007 | | return Response.FromValue(value, message.Response); |
| | 2008 | | } |
| | 2009 | | default: |
| 0 | 2010 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2011 | | } |
| 0 | 2012 | | } |
| | 2013 | |
|
| | 2014 | | internal HttpMessage CreateListAllNextPageRequest(string nextLink) |
| | 2015 | | { |
| 0 | 2016 | | var message = _pipeline.CreateMessage(); |
| 0 | 2017 | | var request = message.Request; |
| 0 | 2018 | | request.Method = RequestMethod.Get; |
| 0 | 2019 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2020 | | uri.Reset(endpoint); |
| 0 | 2021 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 2022 | | request.Uri = uri; |
| 0 | 2023 | | return message; |
| | 2024 | | } |
| | 2025 | |
|
| | 2026 | | /// <summary> Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. |
| | 2027 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 2028 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2029 | | public async Task<Response<VirtualMachineScaleSetListWithLinkResult>> ListAllNextPageAsync(string nextLink, Canc |
| | 2030 | | { |
| 0 | 2031 | | if (nextLink == null) |
| | 2032 | | { |
| 0 | 2033 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 2034 | | } |
| | 2035 | |
|
| 0 | 2036 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 2037 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2038 | | switch (message.Response.Status) |
| | 2039 | | { |
| | 2040 | | case 200: |
| | 2041 | | { |
| 0 | 2042 | | VirtualMachineScaleSetListWithLinkResult value = default; |
| 0 | 2043 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 2044 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2045 | | { |
| 0 | 2046 | | value = null; |
| | 2047 | | } |
| | 2048 | | else |
| | 2049 | | { |
| 0 | 2050 | | value = VirtualMachineScaleSetListWithLinkResult.DeserializeVirtualMachineScaleSetListWithLi |
| | 2051 | | } |
| 0 | 2052 | | return Response.FromValue(value, message.Response); |
| | 2053 | | } |
| | 2054 | | default: |
| 0 | 2055 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2056 | | } |
| 0 | 2057 | | } |
| | 2058 | |
|
| | 2059 | | /// <summary> Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. |
| | 2060 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 2061 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2062 | | public Response<VirtualMachineScaleSetListWithLinkResult> ListAllNextPage(string nextLink, CancellationToken can |
| | 2063 | | { |
| 0 | 2064 | | if (nextLink == null) |
| | 2065 | | { |
| 0 | 2066 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 2067 | | } |
| | 2068 | |
|
| 0 | 2069 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 2070 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2071 | | switch (message.Response.Status) |
| | 2072 | | { |
| | 2073 | | case 200: |
| | 2074 | | { |
| 0 | 2075 | | VirtualMachineScaleSetListWithLinkResult value = default; |
| 0 | 2076 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 2077 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2078 | | { |
| 0 | 2079 | | value = null; |
| | 2080 | | } |
| | 2081 | | else |
| | 2082 | | { |
| 0 | 2083 | | value = VirtualMachineScaleSetListWithLinkResult.DeserializeVirtualMachineScaleSetListWithLi |
| | 2084 | | } |
| 0 | 2085 | | return Response.FromValue(value, message.Response); |
| | 2086 | | } |
| | 2087 | | default: |
| 0 | 2088 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2089 | | } |
| 0 | 2090 | | } |
| | 2091 | |
|
| | 2092 | | internal HttpMessage CreateListSkusNextPageRequest(string nextLink, string resourceGroupName, string vmScaleSetN |
| | 2093 | | { |
| 0 | 2094 | | var message = _pipeline.CreateMessage(); |
| 0 | 2095 | | var request = message.Request; |
| 0 | 2096 | | request.Method = RequestMethod.Get; |
| 0 | 2097 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2098 | | uri.Reset(endpoint); |
| 0 | 2099 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 2100 | | request.Uri = uri; |
| 0 | 2101 | | return message; |
| | 2102 | | } |
| | 2103 | |
|
| | 2104 | | /// <summary> Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instance |
| | 2105 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 2106 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 2107 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 2108 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2109 | | public async Task<Response<VirtualMachineScaleSetListSkusResult>> ListSkusNextPageAsync(string nextLink, string |
| | 2110 | | { |
| 0 | 2111 | | if (nextLink == null) |
| | 2112 | | { |
| 0 | 2113 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 2114 | | } |
| 0 | 2115 | | if (resourceGroupName == null) |
| | 2116 | | { |
| 0 | 2117 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2118 | | } |
| 0 | 2119 | | if (vmScaleSetName == null) |
| | 2120 | | { |
| 0 | 2121 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 2122 | | } |
| | 2123 | |
|
| 0 | 2124 | | using var message = CreateListSkusNextPageRequest(nextLink, resourceGroupName, vmScaleSetName); |
| 0 | 2125 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2126 | | switch (message.Response.Status) |
| | 2127 | | { |
| | 2128 | | case 200: |
| | 2129 | | { |
| 0 | 2130 | | VirtualMachineScaleSetListSkusResult value = default; |
| 0 | 2131 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 2132 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2133 | | { |
| 0 | 2134 | | value = null; |
| | 2135 | | } |
| | 2136 | | else |
| | 2137 | | { |
| 0 | 2138 | | value = VirtualMachineScaleSetListSkusResult.DeserializeVirtualMachineScaleSetListSkusResult |
| | 2139 | | } |
| 0 | 2140 | | return Response.FromValue(value, message.Response); |
| | 2141 | | } |
| | 2142 | | default: |
| 0 | 2143 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2144 | | } |
| 0 | 2145 | | } |
| | 2146 | |
|
| | 2147 | | /// <summary> Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instance |
| | 2148 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 2149 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 2150 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 2151 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2152 | | public Response<VirtualMachineScaleSetListSkusResult> ListSkusNextPage(string nextLink, string resourceGroupName |
| | 2153 | | { |
| 0 | 2154 | | if (nextLink == null) |
| | 2155 | | { |
| 0 | 2156 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 2157 | | } |
| 0 | 2158 | | if (resourceGroupName == null) |
| | 2159 | | { |
| 0 | 2160 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2161 | | } |
| 0 | 2162 | | if (vmScaleSetName == null) |
| | 2163 | | { |
| 0 | 2164 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 2165 | | } |
| | 2166 | |
|
| 0 | 2167 | | using var message = CreateListSkusNextPageRequest(nextLink, resourceGroupName, vmScaleSetName); |
| 0 | 2168 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2169 | | switch (message.Response.Status) |
| | 2170 | | { |
| | 2171 | | case 200: |
| | 2172 | | { |
| 0 | 2173 | | VirtualMachineScaleSetListSkusResult value = default; |
| 0 | 2174 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 2175 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2176 | | { |
| 0 | 2177 | | value = null; |
| | 2178 | | } |
| | 2179 | | else |
| | 2180 | | { |
| 0 | 2181 | | value = VirtualMachineScaleSetListSkusResult.DeserializeVirtualMachineScaleSetListSkusResult |
| | 2182 | | } |
| 0 | 2183 | | return Response.FromValue(value, message.Response); |
| | 2184 | | } |
| | 2185 | | default: |
| 0 | 2186 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2187 | | } |
| 0 | 2188 | | } |
| | 2189 | |
|
| | 2190 | | internal HttpMessage CreateGetOSUpgradeHistoryNextPageRequest(string nextLink, string resourceGroupName, string |
| | 2191 | | { |
| 0 | 2192 | | var message = _pipeline.CreateMessage(); |
| 0 | 2193 | | var request = message.Request; |
| 0 | 2194 | | request.Method = RequestMethod.Get; |
| 0 | 2195 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2196 | | uri.Reset(endpoint); |
| 0 | 2197 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 2198 | | request.Uri = uri; |
| 0 | 2199 | | return message; |
| | 2200 | | } |
| | 2201 | |
|
| | 2202 | | /// <summary> Gets list of OS upgrades on a VM scale set instance. </summary> |
| | 2203 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 2204 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 2205 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 2206 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2207 | | public async Task<Response<VirtualMachineScaleSetListOSUpgradeHistory>> GetOSUpgradeHistoryNextPageAsync(string |
| | 2208 | | { |
| 0 | 2209 | | if (nextLink == null) |
| | 2210 | | { |
| 0 | 2211 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 2212 | | } |
| 0 | 2213 | | if (resourceGroupName == null) |
| | 2214 | | { |
| 0 | 2215 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2216 | | } |
| 0 | 2217 | | if (vmScaleSetName == null) |
| | 2218 | | { |
| 0 | 2219 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 2220 | | } |
| | 2221 | |
|
| 0 | 2222 | | using var message = CreateGetOSUpgradeHistoryNextPageRequest(nextLink, resourceGroupName, vmScaleSetName); |
| 0 | 2223 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2224 | | switch (message.Response.Status) |
| | 2225 | | { |
| | 2226 | | case 200: |
| | 2227 | | { |
| 0 | 2228 | | VirtualMachineScaleSetListOSUpgradeHistory value = default; |
| 0 | 2229 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 2230 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2231 | | { |
| 0 | 2232 | | value = null; |
| | 2233 | | } |
| | 2234 | | else |
| | 2235 | | { |
| 0 | 2236 | | value = VirtualMachineScaleSetListOSUpgradeHistory.DeserializeVirtualMachineScaleSetListOSUp |
| | 2237 | | } |
| 0 | 2238 | | return Response.FromValue(value, message.Response); |
| | 2239 | | } |
| | 2240 | | default: |
| 0 | 2241 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2242 | | } |
| 0 | 2243 | | } |
| | 2244 | |
|
| | 2245 | | /// <summary> Gets list of OS upgrades on a VM scale set instance. </summary> |
| | 2246 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 2247 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 2248 | | /// <param name="vmScaleSetName"> The name of the VM scale set. </param> |
| | 2249 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2250 | | public Response<VirtualMachineScaleSetListOSUpgradeHistory> GetOSUpgradeHistoryNextPage(string nextLink, string |
| | 2251 | | { |
| 0 | 2252 | | if (nextLink == null) |
| | 2253 | | { |
| 0 | 2254 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 2255 | | } |
| 0 | 2256 | | if (resourceGroupName == null) |
| | 2257 | | { |
| 0 | 2258 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2259 | | } |
| 0 | 2260 | | if (vmScaleSetName == null) |
| | 2261 | | { |
| 0 | 2262 | | throw new ArgumentNullException(nameof(vmScaleSetName)); |
| | 2263 | | } |
| | 2264 | |
|
| 0 | 2265 | | using var message = CreateGetOSUpgradeHistoryNextPageRequest(nextLink, resourceGroupName, vmScaleSetName); |
| 0 | 2266 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2267 | | switch (message.Response.Status) |
| | 2268 | | { |
| | 2269 | | case 200: |
| | 2270 | | { |
| 0 | 2271 | | VirtualMachineScaleSetListOSUpgradeHistory value = default; |
| 0 | 2272 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 2273 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2274 | | { |
| 0 | 2275 | | value = null; |
| | 2276 | | } |
| | 2277 | | else |
| | 2278 | | { |
| 0 | 2279 | | value = VirtualMachineScaleSetListOSUpgradeHistory.DeserializeVirtualMachineScaleSetListOSUp |
| | 2280 | | } |
| 0 | 2281 | | return Response.FromValue(value, message.Response); |
| | 2282 | | } |
| | 2283 | | default: |
| 0 | 2284 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2285 | | } |
| 0 | 2286 | | } |
| | 2287 | | } |
| | 2288 | | } |