| | 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.Storage.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Storage |
| | 17 | | { |
| | 18 | | /// <summary> The Usages service client. </summary> |
| | 19 | | public partial class UsagesOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 4 | 23 | | internal UsagesRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of UsagesOperations for mocking. </summary> |
| 240 | 25 | | protected UsagesOperations() |
| | 26 | | { |
| 240 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of UsagesOperations. </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"> The ID of the target subscription. </param> |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| | 33 | | /// <param name="apiVersion"> Api Version. </param> |
| 240 | 34 | | internal UsagesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri |
| | 35 | | { |
| 240 | 36 | | RestClient = new UsagesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint, apiVersion); |
| 240 | 37 | | _clientDiagnostics = clientDiagnostics; |
| 240 | 38 | | _pipeline = pipeline; |
| 240 | 39 | | } |
| | 40 | |
|
| | 41 | | /// <summary> Gets the current usage count and the limit for the resources of the location under the subscriptio |
| | 42 | | /// <param name="location"> The location of the Azure Storage resource. </param> |
| | 43 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 44 | | public virtual AsyncPageable<Usage> ListByLocationAsync(string location, CancellationToken cancellationToken = d |
| | 45 | | { |
| 2 | 46 | | if (location == null) |
| | 47 | | { |
| 0 | 48 | | throw new ArgumentNullException(nameof(location)); |
| | 49 | | } |
| | 50 | |
|
| | 51 | | async Task<Page<Usage>> FirstPageFunc(int? pageSizeHint) |
| | 52 | | { |
| 2 | 53 | | using var scope = _clientDiagnostics.CreateScope("UsagesOperations.ListByLocation"); |
| 2 | 54 | | scope.Start(); |
| | 55 | | try |
| | 56 | | { |
| 2 | 57 | | var response = await RestClient.ListByLocationAsync(location, cancellationToken).ConfigureAwait(fals |
| 2 | 58 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 59 | | } |
| 0 | 60 | | catch (Exception e) |
| | 61 | | { |
| 0 | 62 | | scope.Failed(e); |
| 0 | 63 | | throw; |
| | 64 | | } |
| 2 | 65 | | } |
| 2 | 66 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); |
| | 67 | | } |
| | 68 | |
|
| | 69 | | /// <summary> Gets the current usage count and the limit for the resources of the location under the subscriptio |
| | 70 | | /// <param name="location"> The location of the Azure Storage resource. </param> |
| | 71 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 72 | | public virtual Pageable<Usage> ListByLocation(string location, CancellationToken cancellationToken = default) |
| | 73 | | { |
| 2 | 74 | | if (location == null) |
| | 75 | | { |
| 0 | 76 | | throw new ArgumentNullException(nameof(location)); |
| | 77 | | } |
| | 78 | |
|
| | 79 | | Page<Usage> FirstPageFunc(int? pageSizeHint) |
| | 80 | | { |
| 2 | 81 | | using var scope = _clientDiagnostics.CreateScope("UsagesOperations.ListByLocation"); |
| 2 | 82 | | scope.Start(); |
| | 83 | | try |
| | 84 | | { |
| 2 | 85 | | var response = RestClient.ListByLocation(location, cancellationToken); |
| 2 | 86 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 87 | | } |
| 0 | 88 | | catch (Exception e) |
| | 89 | | { |
| 0 | 90 | | scope.Failed(e); |
| 0 | 91 | | throw; |
| | 92 | | } |
| 2 | 93 | | } |
| 2 | 94 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, null); |
| | 95 | | } |
| | 96 | | } |
| | 97 | | } |