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