| | 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 VirtualMachineExtensionsRestOperations |
| | 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 VirtualMachineExtensionsRestOperations. </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 VirtualMachineExtensionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string |
| | 33 | | { |
| 396 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 396 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 396 | 40 | | this.subscriptionId = subscriptionId; |
| 396 | 41 | | this.endpoint = endpoint; |
| 396 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 43 | | _pipeline = pipeline; |
| 396 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string vmName, string vmExtensionName |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Put; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 57 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false); |
| 0 | 58 | | uri.AppendPath(vmName, true); |
| 0 | 59 | | uri.AppendPath("/extensions/", false); |
| 0 | 60 | | uri.AppendPath(vmExtensionName, true); |
| 0 | 61 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 62 | | request.Uri = uri; |
| 0 | 63 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 64 | | var content = new Utf8JsonRequestContent(); |
| 0 | 65 | | content.JsonWriter.WriteObjectValue(extensionParameters); |
| 0 | 66 | | request.Content = content; |
| 0 | 67 | | return message; |
| | 68 | | } |
| | 69 | |
|
| | 70 | | /// <summary> The operation to create or update the extension. </summary> |
| | 71 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 72 | | /// <param name="vmName"> The name of the virtual machine where the extension should be created or updated. </pa |
| | 73 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 74 | | /// <param name="extensionParameters"> Parameters supplied to the Create Virtual Machine Extension operation. </ |
| | 75 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 76 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string vmName, string vmExtensionName, |
| | 77 | | { |
| 0 | 78 | | if (resourceGroupName == null) |
| | 79 | | { |
| 0 | 80 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 81 | | } |
| 0 | 82 | | if (vmName == null) |
| | 83 | | { |
| 0 | 84 | | throw new ArgumentNullException(nameof(vmName)); |
| | 85 | | } |
| 0 | 86 | | if (vmExtensionName == null) |
| | 87 | | { |
| 0 | 88 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 89 | | } |
| 0 | 90 | | if (extensionParameters == null) |
| | 91 | | { |
| 0 | 92 | | throw new ArgumentNullException(nameof(extensionParameters)); |
| | 93 | | } |
| | 94 | |
|
| 0 | 95 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, vmName, vmExtensionName, extensionParamet |
| 0 | 96 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 97 | | switch (message.Response.Status) |
| | 98 | | { |
| | 99 | | case 200: |
| | 100 | | case 201: |
| 0 | 101 | | return message.Response; |
| | 102 | | default: |
| 0 | 103 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 104 | | } |
| 0 | 105 | | } |
| | 106 | |
|
| | 107 | | /// <summary> The operation to create or update the extension. </summary> |
| | 108 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 109 | | /// <param name="vmName"> The name of the virtual machine where the extension should be created or updated. </pa |
| | 110 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 111 | | /// <param name="extensionParameters"> Parameters supplied to the Create Virtual Machine Extension operation. </ |
| | 112 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 113 | | public Response CreateOrUpdate(string resourceGroupName, string vmName, string vmExtensionName, VirtualMachineEx |
| | 114 | | { |
| 0 | 115 | | if (resourceGroupName == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 118 | | } |
| 0 | 119 | | if (vmName == null) |
| | 120 | | { |
| 0 | 121 | | throw new ArgumentNullException(nameof(vmName)); |
| | 122 | | } |
| 0 | 123 | | if (vmExtensionName == null) |
| | 124 | | { |
| 0 | 125 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 126 | | } |
| 0 | 127 | | if (extensionParameters == null) |
| | 128 | | { |
| 0 | 129 | | throw new ArgumentNullException(nameof(extensionParameters)); |
| | 130 | | } |
| | 131 | |
|
| 0 | 132 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, vmName, vmExtensionName, extensionParamet |
| 0 | 133 | | _pipeline.Send(message, cancellationToken); |
| 0 | 134 | | switch (message.Response.Status) |
| | 135 | | { |
| | 136 | | case 200: |
| | 137 | | case 201: |
| 0 | 138 | | return message.Response; |
| | 139 | | default: |
| 0 | 140 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 141 | | } |
| 0 | 142 | | } |
| | 143 | |
|
| | 144 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string vmName, string vmExtensionName, Virtua |
| | 145 | | { |
| 0 | 146 | | var message = _pipeline.CreateMessage(); |
| 0 | 147 | | var request = message.Request; |
| 0 | 148 | | request.Method = RequestMethod.Patch; |
| 0 | 149 | | var uri = new RawRequestUriBuilder(); |
| 0 | 150 | | uri.Reset(endpoint); |
| 0 | 151 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 152 | | uri.AppendPath(subscriptionId, true); |
| 0 | 153 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 154 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 155 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false); |
| 0 | 156 | | uri.AppendPath(vmName, true); |
| 0 | 157 | | uri.AppendPath("/extensions/", false); |
| 0 | 158 | | uri.AppendPath(vmExtensionName, true); |
| 0 | 159 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 160 | | request.Uri = uri; |
| 0 | 161 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 162 | | var content = new Utf8JsonRequestContent(); |
| 0 | 163 | | content.JsonWriter.WriteObjectValue(extensionParameters); |
| 0 | 164 | | request.Content = content; |
| 0 | 165 | | return message; |
| | 166 | | } |
| | 167 | |
|
| | 168 | | /// <summary> The operation to update the extension. </summary> |
| | 169 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 170 | | /// <param name="vmName"> The name of the virtual machine where the extension should be updated. </param> |
| | 171 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 172 | | /// <param name="extensionParameters"> Parameters supplied to the Update Virtual Machine Extension operation. </ |
| | 173 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 174 | | public async Task<Response> UpdateAsync(string resourceGroupName, string vmName, string vmExtensionName, Virtual |
| | 175 | | { |
| 0 | 176 | | if (resourceGroupName == null) |
| | 177 | | { |
| 0 | 178 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 179 | | } |
| 0 | 180 | | if (vmName == null) |
| | 181 | | { |
| 0 | 182 | | throw new ArgumentNullException(nameof(vmName)); |
| | 183 | | } |
| 0 | 184 | | if (vmExtensionName == null) |
| | 185 | | { |
| 0 | 186 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 187 | | } |
| 0 | 188 | | if (extensionParameters == null) |
| | 189 | | { |
| 0 | 190 | | throw new ArgumentNullException(nameof(extensionParameters)); |
| | 191 | | } |
| | 192 | |
|
| 0 | 193 | | using var message = CreateUpdateRequest(resourceGroupName, vmName, vmExtensionName, extensionParameters); |
| 0 | 194 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 195 | | switch (message.Response.Status) |
| | 196 | | { |
| | 197 | | case 200: |
| 0 | 198 | | return message.Response; |
| | 199 | | default: |
| 0 | 200 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 201 | | } |
| 0 | 202 | | } |
| | 203 | |
|
| | 204 | | /// <summary> The operation to update the extension. </summary> |
| | 205 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 206 | | /// <param name="vmName"> The name of the virtual machine where the extension should be updated. </param> |
| | 207 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 208 | | /// <param name="extensionParameters"> Parameters supplied to the Update Virtual Machine Extension operation. </ |
| | 209 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 210 | | public Response Update(string resourceGroupName, string vmName, string vmExtensionName, VirtualMachineExtensionU |
| | 211 | | { |
| 0 | 212 | | if (resourceGroupName == null) |
| | 213 | | { |
| 0 | 214 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 215 | | } |
| 0 | 216 | | if (vmName == null) |
| | 217 | | { |
| 0 | 218 | | throw new ArgumentNullException(nameof(vmName)); |
| | 219 | | } |
| 0 | 220 | | if (vmExtensionName == null) |
| | 221 | | { |
| 0 | 222 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 223 | | } |
| 0 | 224 | | if (extensionParameters == null) |
| | 225 | | { |
| 0 | 226 | | throw new ArgumentNullException(nameof(extensionParameters)); |
| | 227 | | } |
| | 228 | |
|
| 0 | 229 | | using var message = CreateUpdateRequest(resourceGroupName, vmName, vmExtensionName, extensionParameters); |
| 0 | 230 | | _pipeline.Send(message, cancellationToken); |
| 0 | 231 | | switch (message.Response.Status) |
| | 232 | | { |
| | 233 | | case 200: |
| 0 | 234 | | return message.Response; |
| | 235 | | default: |
| 0 | 236 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 237 | | } |
| 0 | 238 | | } |
| | 239 | |
|
| | 240 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string vmName, string vmExtensionName) |
| | 241 | | { |
| 0 | 242 | | var message = _pipeline.CreateMessage(); |
| 0 | 243 | | var request = message.Request; |
| 0 | 244 | | request.Method = RequestMethod.Delete; |
| 0 | 245 | | var uri = new RawRequestUriBuilder(); |
| 0 | 246 | | uri.Reset(endpoint); |
| 0 | 247 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 248 | | uri.AppendPath(subscriptionId, true); |
| 0 | 249 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 250 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 251 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false); |
| 0 | 252 | | uri.AppendPath(vmName, true); |
| 0 | 253 | | uri.AppendPath("/extensions/", false); |
| 0 | 254 | | uri.AppendPath(vmExtensionName, true); |
| 0 | 255 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 256 | | request.Uri = uri; |
| 0 | 257 | | return message; |
| | 258 | | } |
| | 259 | |
|
| | 260 | | /// <summary> The operation to delete the extension. </summary> |
| | 261 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 262 | | /// <param name="vmName"> The name of the virtual machine where the extension should be deleted. </param> |
| | 263 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 264 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 265 | | public async Task<Response> DeleteAsync(string resourceGroupName, string vmName, string vmExtensionName, Cancell |
| | 266 | | { |
| 0 | 267 | | if (resourceGroupName == null) |
| | 268 | | { |
| 0 | 269 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 270 | | } |
| 0 | 271 | | if (vmName == null) |
| | 272 | | { |
| 0 | 273 | | throw new ArgumentNullException(nameof(vmName)); |
| | 274 | | } |
| 0 | 275 | | if (vmExtensionName == null) |
| | 276 | | { |
| 0 | 277 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 278 | | } |
| | 279 | |
|
| 0 | 280 | | using var message = CreateDeleteRequest(resourceGroupName, vmName, vmExtensionName); |
| 0 | 281 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 282 | | switch (message.Response.Status) |
| | 283 | | { |
| | 284 | | case 200: |
| | 285 | | case 202: |
| | 286 | | case 204: |
| 0 | 287 | | return message.Response; |
| | 288 | | default: |
| 0 | 289 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 290 | | } |
| 0 | 291 | | } |
| | 292 | |
|
| | 293 | | /// <summary> The operation to delete the extension. </summary> |
| | 294 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 295 | | /// <param name="vmName"> The name of the virtual machine where the extension should be deleted. </param> |
| | 296 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 297 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 298 | | public Response Delete(string resourceGroupName, string vmName, string vmExtensionName, CancellationToken cancel |
| | 299 | | { |
| 0 | 300 | | if (resourceGroupName == null) |
| | 301 | | { |
| 0 | 302 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 303 | | } |
| 0 | 304 | | if (vmName == null) |
| | 305 | | { |
| 0 | 306 | | throw new ArgumentNullException(nameof(vmName)); |
| | 307 | | } |
| 0 | 308 | | if (vmExtensionName == null) |
| | 309 | | { |
| 0 | 310 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 311 | | } |
| | 312 | |
|
| 0 | 313 | | using var message = CreateDeleteRequest(resourceGroupName, vmName, vmExtensionName); |
| 0 | 314 | | _pipeline.Send(message, cancellationToken); |
| 0 | 315 | | switch (message.Response.Status) |
| | 316 | | { |
| | 317 | | case 200: |
| | 318 | | case 202: |
| | 319 | | case 204: |
| 0 | 320 | | return message.Response; |
| | 321 | | default: |
| 0 | 322 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 323 | | } |
| 0 | 324 | | } |
| | 325 | |
|
| | 326 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string vmName, string vmExtensionName, string ex |
| | 327 | | { |
| 0 | 328 | | var message = _pipeline.CreateMessage(); |
| 0 | 329 | | var request = message.Request; |
| 0 | 330 | | request.Method = RequestMethod.Get; |
| 0 | 331 | | var uri = new RawRequestUriBuilder(); |
| 0 | 332 | | uri.Reset(endpoint); |
| 0 | 333 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 334 | | uri.AppendPath(subscriptionId, true); |
| 0 | 335 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 336 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 337 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false); |
| 0 | 338 | | uri.AppendPath(vmName, true); |
| 0 | 339 | | uri.AppendPath("/extensions/", false); |
| 0 | 340 | | uri.AppendPath(vmExtensionName, true); |
| 0 | 341 | | if (expand != null) |
| | 342 | | { |
| 0 | 343 | | uri.AppendQuery("$expand", expand, true); |
| | 344 | | } |
| 0 | 345 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 346 | | request.Uri = uri; |
| 0 | 347 | | return message; |
| | 348 | | } |
| | 349 | |
|
| | 350 | | /// <summary> The operation to get the extension. </summary> |
| | 351 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 352 | | /// <param name="vmName"> The name of the virtual machine containing the extension. </param> |
| | 353 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 354 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 355 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 356 | | public async Task<Response<VirtualMachineExtension>> GetAsync(string resourceGroupName, string vmName, string vm |
| | 357 | | { |
| 0 | 358 | | if (resourceGroupName == null) |
| | 359 | | { |
| 0 | 360 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 361 | | } |
| 0 | 362 | | if (vmName == null) |
| | 363 | | { |
| 0 | 364 | | throw new ArgumentNullException(nameof(vmName)); |
| | 365 | | } |
| 0 | 366 | | if (vmExtensionName == null) |
| | 367 | | { |
| 0 | 368 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 369 | | } |
| | 370 | |
|
| 0 | 371 | | using var message = CreateGetRequest(resourceGroupName, vmName, vmExtensionName, expand); |
| 0 | 372 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 373 | | switch (message.Response.Status) |
| | 374 | | { |
| | 375 | | case 200: |
| | 376 | | { |
| 0 | 377 | | VirtualMachineExtension value = default; |
| 0 | 378 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 379 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 380 | | { |
| 0 | 381 | | value = null; |
| | 382 | | } |
| | 383 | | else |
| | 384 | | { |
| 0 | 385 | | value = VirtualMachineExtension.DeserializeVirtualMachineExtension(document.RootElement); |
| | 386 | | } |
| 0 | 387 | | return Response.FromValue(value, message.Response); |
| | 388 | | } |
| | 389 | | default: |
| 0 | 390 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 391 | | } |
| 0 | 392 | | } |
| | 393 | |
|
| | 394 | | /// <summary> The operation to get the extension. </summary> |
| | 395 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 396 | | /// <param name="vmName"> The name of the virtual machine containing the extension. </param> |
| | 397 | | /// <param name="vmExtensionName"> The name of the virtual machine extension. </param> |
| | 398 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 399 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 400 | | public Response<VirtualMachineExtension> Get(string resourceGroupName, string vmName, string vmExtensionName, st |
| | 401 | | { |
| 0 | 402 | | if (resourceGroupName == null) |
| | 403 | | { |
| 0 | 404 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 405 | | } |
| 0 | 406 | | if (vmName == null) |
| | 407 | | { |
| 0 | 408 | | throw new ArgumentNullException(nameof(vmName)); |
| | 409 | | } |
| 0 | 410 | | if (vmExtensionName == null) |
| | 411 | | { |
| 0 | 412 | | throw new ArgumentNullException(nameof(vmExtensionName)); |
| | 413 | | } |
| | 414 | |
|
| 0 | 415 | | using var message = CreateGetRequest(resourceGroupName, vmName, vmExtensionName, expand); |
| 0 | 416 | | _pipeline.Send(message, cancellationToken); |
| 0 | 417 | | switch (message.Response.Status) |
| | 418 | | { |
| | 419 | | case 200: |
| | 420 | | { |
| 0 | 421 | | VirtualMachineExtension value = default; |
| 0 | 422 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 423 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 424 | | { |
| 0 | 425 | | value = null; |
| | 426 | | } |
| | 427 | | else |
| | 428 | | { |
| 0 | 429 | | value = VirtualMachineExtension.DeserializeVirtualMachineExtension(document.RootElement); |
| | 430 | | } |
| 0 | 431 | | return Response.FromValue(value, message.Response); |
| | 432 | | } |
| | 433 | | default: |
| 0 | 434 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 435 | | } |
| 0 | 436 | | } |
| | 437 | |
|
| | 438 | | internal HttpMessage CreateListRequest(string resourceGroupName, string vmName, string expand) |
| | 439 | | { |
| 0 | 440 | | var message = _pipeline.CreateMessage(); |
| 0 | 441 | | var request = message.Request; |
| 0 | 442 | | request.Method = RequestMethod.Get; |
| 0 | 443 | | var uri = new RawRequestUriBuilder(); |
| 0 | 444 | | uri.Reset(endpoint); |
| 0 | 445 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 446 | | uri.AppendPath(subscriptionId, true); |
| 0 | 447 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 448 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 449 | | uri.AppendPath("/providers/Microsoft.Compute/virtualMachines/", false); |
| 0 | 450 | | uri.AppendPath(vmName, true); |
| 0 | 451 | | uri.AppendPath("/extensions", false); |
| 0 | 452 | | if (expand != null) |
| | 453 | | { |
| 0 | 454 | | uri.AppendQuery("$expand", expand, true); |
| | 455 | | } |
| 0 | 456 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 457 | | request.Uri = uri; |
| 0 | 458 | | return message; |
| | 459 | | } |
| | 460 | |
|
| | 461 | | /// <summary> The operation to get all extensions of a Virtual Machine. </summary> |
| | 462 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 463 | | /// <param name="vmName"> The name of the virtual machine containing the extension. </param> |
| | 464 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 465 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 466 | | public async Task<Response<VirtualMachineExtensionsListResult>> ListAsync(string resourceGroupName, string vmNam |
| | 467 | | { |
| 0 | 468 | | if (resourceGroupName == null) |
| | 469 | | { |
| 0 | 470 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 471 | | } |
| 0 | 472 | | if (vmName == null) |
| | 473 | | { |
| 0 | 474 | | throw new ArgumentNullException(nameof(vmName)); |
| | 475 | | } |
| | 476 | |
|
| 0 | 477 | | using var message = CreateListRequest(resourceGroupName, vmName, expand); |
| 0 | 478 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 479 | | switch (message.Response.Status) |
| | 480 | | { |
| | 481 | | case 200: |
| | 482 | | { |
| 0 | 483 | | VirtualMachineExtensionsListResult value = default; |
| 0 | 484 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 485 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 486 | | { |
| 0 | 487 | | value = null; |
| | 488 | | } |
| | 489 | | else |
| | 490 | | { |
| 0 | 491 | | value = VirtualMachineExtensionsListResult.DeserializeVirtualMachineExtensionsListResult(doc |
| | 492 | | } |
| 0 | 493 | | return Response.FromValue(value, message.Response); |
| | 494 | | } |
| | 495 | | default: |
| 0 | 496 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 497 | | } |
| 0 | 498 | | } |
| | 499 | |
|
| | 500 | | /// <summary> The operation to get all extensions of a Virtual Machine. </summary> |
| | 501 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 502 | | /// <param name="vmName"> The name of the virtual machine containing the extension. </param> |
| | 503 | | /// <param name="expand"> The expand expression to apply on the operation. </param> |
| | 504 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 505 | | public Response<VirtualMachineExtensionsListResult> List(string resourceGroupName, string vmName, string expand |
| | 506 | | { |
| 0 | 507 | | if (resourceGroupName == null) |
| | 508 | | { |
| 0 | 509 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 510 | | } |
| 0 | 511 | | if (vmName == null) |
| | 512 | | { |
| 0 | 513 | | throw new ArgumentNullException(nameof(vmName)); |
| | 514 | | } |
| | 515 | |
|
| 0 | 516 | | using var message = CreateListRequest(resourceGroupName, vmName, expand); |
| 0 | 517 | | _pipeline.Send(message, cancellationToken); |
| 0 | 518 | | switch (message.Response.Status) |
| | 519 | | { |
| | 520 | | case 200: |
| | 521 | | { |
| 0 | 522 | | VirtualMachineExtensionsListResult value = default; |
| 0 | 523 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 524 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 525 | | { |
| 0 | 526 | | value = null; |
| | 527 | | } |
| | 528 | | else |
| | 529 | | { |
| 0 | 530 | | value = VirtualMachineExtensionsListResult.DeserializeVirtualMachineExtensionsListResult(doc |
| | 531 | | } |
| 0 | 532 | | return Response.FromValue(value, message.Response); |
| | 533 | | } |
| | 534 | | default: |
| 0 | 535 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 536 | | } |
| 0 | 537 | | } |
| | 538 | | } |
| | 539 | | } |