| | 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.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Compute.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Compute |
| | 17 | | { |
| | 18 | | /// <summary> The VirtualMachineSizes service client. </summary> |
| | 19 | | public partial class VirtualMachineSizesOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 4 | 23 | | internal VirtualMachineSizesRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of VirtualMachineSizesOperations for mocking. </summary> |
| 396 | 25 | | protected VirtualMachineSizesOperations() |
| | 26 | | { |
| 396 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of VirtualMachineSizesOperations. </summary> |
| | 29 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 30 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 31 | | /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 396 | 33 | | internal VirtualMachineSizesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscr |
| | 34 | | { |
| 396 | 35 | | RestClient = new VirtualMachineSizesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 396 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 37 | | _pipeline = pipeline; |
| 396 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res |
| | 41 | | /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param> |
| | 42 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 43 | | public virtual AsyncPageable<VirtualMachineSize> ListAsync(string location, CancellationToken cancellationToken |
| | 44 | | { |
| 2 | 45 | | if (location == null) |
| | 46 | | { |
| 0 | 47 | | throw new ArgumentNullException(nameof(location)); |
| | 48 | | } |
| | 49 | |
|
| | 50 | | async Task<Page<VirtualMachineSize>> FirstPageFunc(int? pageSizeHint) |
| | 51 | | { |
| 2 | 52 | | using var scope = _clientDiagnostics.CreateScope("VirtualMachineSizesOperations.List"); |
| 2 | 53 | | scope.Start(); |
| | 54 | | try |
| | 55 | | { |
| 2 | 56 | | var response = await RestClient.ListAsync(location, cancellationToken).ConfigureAwait(false); |
| 2 | 57 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 58 | | } |
| 0 | 59 | | catch (Exception e) |
| | 60 | | { |
| 0 | 61 | | scope.Failed(e); |
| 0 | 62 | | throw; |
| | 63 | | } |
| 2 | 64 | | } |
| 2 | 65 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); |
| | 66 | | } |
| | 67 | |
|
| | 68 | | /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res |
| | 69 | | /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param> |
| | 70 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 71 | | public virtual Pageable<VirtualMachineSize> List(string location, CancellationToken cancellationToken = default) |
| | 72 | | { |
| 2 | 73 | | if (location == null) |
| | 74 | | { |
| 0 | 75 | | throw new ArgumentNullException(nameof(location)); |
| | 76 | | } |
| | 77 | |
|
| | 78 | | Page<VirtualMachineSize> FirstPageFunc(int? pageSizeHint) |
| | 79 | | { |
| 2 | 80 | | using var scope = _clientDiagnostics.CreateScope("VirtualMachineSizesOperations.List"); |
| 2 | 81 | | scope.Start(); |
| | 82 | | try |
| | 83 | | { |
| 2 | 84 | | var response = RestClient.List(location, cancellationToken); |
| 2 | 85 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 86 | | } |
| 0 | 87 | | catch (Exception e) |
| | 88 | | { |
| 0 | 89 | | scope.Failed(e); |
| 0 | 90 | | throw; |
| | 91 | | } |
| 2 | 92 | | } |
| 2 | 93 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, null); |
| | 94 | | } |
| | 95 | | } |
| | 96 | | } |