| | 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.EventHubs.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.EventHubs |
| | 17 | | { |
| | 18 | | /// <summary> The Regions service client. </summary> |
| | 19 | | public partial class RegionsOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 0 | 23 | | internal RegionsRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of RegionsOperations for mocking. </summary> |
| 0 | 25 | | protected RegionsOperations() |
| | 26 | | { |
| 0 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of RegionsOperations. </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 that uniquely identify a Microsoft Azure subscription |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 0 | 33 | | internal RegionsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Ur |
| | 34 | | { |
| 0 | 35 | | RestClient = new RegionsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 0 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 37 | | _pipeline = pipeline; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Gets the available Regions for a given sku. </summary> |
| | 41 | | /// <param name="sku"> The sku type. </param> |
| | 42 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 43 | | public virtual AsyncPageable<MessagingRegions> ListBySkuAsync(string sku, CancellationToken cancellationToken = |
| | 44 | | { |
| 0 | 45 | | if (sku == null) |
| | 46 | | { |
| 0 | 47 | | throw new ArgumentNullException(nameof(sku)); |
| | 48 | | } |
| | 49 | |
|
| | 50 | | async Task<Page<MessagingRegions>> FirstPageFunc(int? pageSizeHint) |
| | 51 | | { |
| 0 | 52 | | using var scope = _clientDiagnostics.CreateScope("RegionsOperations.ListBySku"); |
| 0 | 53 | | scope.Start(); |
| | 54 | | try |
| | 55 | | { |
| 0 | 56 | | var response = await RestClient.ListBySkuAsync(sku, cancellationToken).ConfigureAwait(false); |
| 0 | 57 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 58 | | } |
| 0 | 59 | | catch (Exception e) |
| | 60 | | { |
| 0 | 61 | | scope.Failed(e); |
| 0 | 62 | | throw; |
| | 63 | | } |
| 0 | 64 | | } |
| | 65 | | async Task<Page<MessagingRegions>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 66 | | { |
| 0 | 67 | | using var scope = _clientDiagnostics.CreateScope("RegionsOperations.ListBySku"); |
| 0 | 68 | | scope.Start(); |
| | 69 | | try |
| | 70 | | { |
| 0 | 71 | | var response = await RestClient.ListBySkuNextPageAsync(nextLink, sku, cancellationToken).ConfigureAw |
| 0 | 72 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 73 | | } |
| 0 | 74 | | catch (Exception e) |
| | 75 | | { |
| 0 | 76 | | scope.Failed(e); |
| 0 | 77 | | throw; |
| | 78 | | } |
| 0 | 79 | | } |
| 0 | 80 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 81 | | } |
| | 82 | |
|
| | 83 | | /// <summary> Gets the available Regions for a given sku. </summary> |
| | 84 | | /// <param name="sku"> The sku type. </param> |
| | 85 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 86 | | public virtual Pageable<MessagingRegions> ListBySku(string sku, CancellationToken cancellationToken = default) |
| | 87 | | { |
| 0 | 88 | | if (sku == null) |
| | 89 | | { |
| 0 | 90 | | throw new ArgumentNullException(nameof(sku)); |
| | 91 | | } |
| | 92 | |
|
| | 93 | | Page<MessagingRegions> FirstPageFunc(int? pageSizeHint) |
| | 94 | | { |
| 0 | 95 | | using var scope = _clientDiagnostics.CreateScope("RegionsOperations.ListBySku"); |
| 0 | 96 | | scope.Start(); |
| | 97 | | try |
| | 98 | | { |
| 0 | 99 | | var response = RestClient.ListBySku(sku, cancellationToken); |
| 0 | 100 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 101 | | } |
| 0 | 102 | | catch (Exception e) |
| | 103 | | { |
| 0 | 104 | | scope.Failed(e); |
| 0 | 105 | | throw; |
| | 106 | | } |
| 0 | 107 | | } |
| | 108 | | Page<MessagingRegions> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 109 | | { |
| 0 | 110 | | using var scope = _clientDiagnostics.CreateScope("RegionsOperations.ListBySku"); |
| 0 | 111 | | scope.Start(); |
| | 112 | | try |
| | 113 | | { |
| 0 | 114 | | var response = RestClient.ListBySkuNextPage(nextLink, sku, cancellationToken); |
| 0 | 115 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 116 | | } |
| 0 | 117 | | catch (Exception e) |
| | 118 | | { |
| 0 | 119 | | scope.Failed(e); |
| 0 | 120 | | throw; |
| | 121 | | } |
| 0 | 122 | | } |
| 0 | 123 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 124 | | } |
| | 125 | | } |
| | 126 | | } |