| | 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 ResourceSkus service client. </summary> |
| | 19 | | public partial class ResourceSkusOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 4 | 23 | | internal ResourceSkusRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of ResourceSkusOperations for mocking. </summary> |
| 396 | 25 | | protected ResourceSkusOperations() |
| | 26 | | { |
| 396 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of ResourceSkusOperations. </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 ResourceSkusOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionI |
| | 34 | | { |
| 396 | 35 | | RestClient = new ResourceSkusRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 396 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 37 | | _pipeline = pipeline; |
| 396 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary> |
| | 41 | | /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently. |
| | 42 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 43 | | public virtual AsyncPageable<ResourceSku> ListAsync(string filter = null, CancellationToken cancellationToken = |
| | 44 | | { |
| | 45 | | async Task<Page<ResourceSku>> FirstPageFunc(int? pageSizeHint) |
| | 46 | | { |
| 2 | 47 | | using var scope = _clientDiagnostics.CreateScope("ResourceSkusOperations.List"); |
| 2 | 48 | | scope.Start(); |
| | 49 | | try |
| | 50 | | { |
| 2 | 51 | | var response = await RestClient.ListAsync(filter, cancellationToken).ConfigureAwait(false); |
| 2 | 52 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 53 | | } |
| 0 | 54 | | catch (Exception e) |
| | 55 | | { |
| 0 | 56 | | scope.Failed(e); |
| 0 | 57 | | throw; |
| | 58 | | } |
| 2 | 59 | | } |
| | 60 | | async Task<Page<ResourceSku>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 61 | | { |
| 0 | 62 | | using var scope = _clientDiagnostics.CreateScope("ResourceSkusOperations.List"); |
| 0 | 63 | | scope.Start(); |
| | 64 | | try |
| | 65 | | { |
| 0 | 66 | | var response = await RestClient.ListNextPageAsync(nextLink, filter, cancellationToken).ConfigureAwai |
| 0 | 67 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 68 | | } |
| 0 | 69 | | catch (Exception e) |
| | 70 | | { |
| 0 | 71 | | scope.Failed(e); |
| 0 | 72 | | throw; |
| | 73 | | } |
| 0 | 74 | | } |
| 2 | 75 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 76 | | } |
| | 77 | |
|
| | 78 | | /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary> |
| | 79 | | /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently. |
| | 80 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 81 | | public virtual Pageable<ResourceSku> List(string filter = null, CancellationToken cancellationToken = default) |
| | 82 | | { |
| | 83 | | Page<ResourceSku> FirstPageFunc(int? pageSizeHint) |
| | 84 | | { |
| 2 | 85 | | using var scope = _clientDiagnostics.CreateScope("ResourceSkusOperations.List"); |
| 2 | 86 | | scope.Start(); |
| | 87 | | try |
| | 88 | | { |
| 2 | 89 | | var response = RestClient.List(filter, cancellationToken); |
| 2 | 90 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 91 | | } |
| 0 | 92 | | catch (Exception e) |
| | 93 | | { |
| 0 | 94 | | scope.Failed(e); |
| 0 | 95 | | throw; |
| | 96 | | } |
| 2 | 97 | | } |
| | 98 | | Page<ResourceSku> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 99 | | { |
| 0 | 100 | | using var scope = _clientDiagnostics.CreateScope("ResourceSkusOperations.List"); |
| 0 | 101 | | scope.Start(); |
| | 102 | | try |
| | 103 | | { |
| 0 | 104 | | var response = RestClient.ListNextPage(nextLink, filter, cancellationToken); |
| 0 | 105 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 106 | | } |
| 0 | 107 | | catch (Exception e) |
| | 108 | | { |
| 0 | 109 | | scope.Failed(e); |
| 0 | 110 | | throw; |
| | 111 | | } |
| 0 | 112 | | } |
| 2 | 113 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 114 | | } |
| | 115 | | } |
| | 116 | | } |