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