| | 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.Resources.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Resources |
| | 17 | | { |
| | 18 | | /// <summary> The Subscriptions service client. </summary> |
| | 19 | | public partial class SubscriptionsOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 20 | 23 | | internal SubscriptionsRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of SubscriptionsOperations for mocking. </summary> |
| 268 | 25 | | protected SubscriptionsOperations() |
| | 26 | | { |
| 268 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of SubscriptionsOperations. </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="endpoint"> server parameter. </param> |
| 268 | 32 | | internal SubscriptionsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null |
| | 33 | | { |
| 268 | 34 | | RestClient = new SubscriptionsRestOperations(clientDiagnostics, pipeline, endpoint); |
| 268 | 35 | | _clientDiagnostics = clientDiagnostics; |
| 268 | 36 | | _pipeline = pipeline; |
| 268 | 37 | | } |
| | 38 | |
|
| | 39 | | /// <summary> Gets details about a specified subscription. </summary> |
| | 40 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 41 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 42 | | public virtual async Task<Response<Subscription>> GetAsync(string subscriptionId, CancellationToken cancellation |
| | 43 | | { |
| 4 | 44 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.Get"); |
| 4 | 45 | | scope.Start(); |
| | 46 | | try |
| | 47 | | { |
| 4 | 48 | | return await RestClient.GetAsync(subscriptionId, cancellationToken).ConfigureAwait(false); |
| | 49 | | } |
| 0 | 50 | | catch (Exception e) |
| | 51 | | { |
| 0 | 52 | | scope.Failed(e); |
| 0 | 53 | | throw; |
| | 54 | | } |
| 4 | 55 | | } |
| | 56 | |
|
| | 57 | | /// <summary> Gets details about a specified subscription. </summary> |
| | 58 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 59 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 60 | | public virtual Response<Subscription> Get(string subscriptionId, CancellationToken cancellationToken = default) |
| | 61 | | { |
| 4 | 62 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.Get"); |
| 4 | 63 | | scope.Start(); |
| | 64 | | try |
| | 65 | | { |
| 4 | 66 | | return RestClient.Get(subscriptionId, cancellationToken); |
| | 67 | | } |
| 0 | 68 | | catch (Exception e) |
| | 69 | | { |
| 0 | 70 | | scope.Failed(e); |
| 0 | 71 | | throw; |
| | 72 | | } |
| 4 | 73 | | } |
| | 74 | |
|
| | 75 | | /// <summary> This operation provides all the locations that are available for resource providers; however, each |
| | 76 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 77 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 78 | | public virtual AsyncPageable<Location> ListLocationsAsync(string subscriptionId, CancellationToken cancellationT |
| | 79 | | { |
| 2 | 80 | | if (subscriptionId == null) |
| | 81 | | { |
| 0 | 82 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 83 | | } |
| | 84 | |
|
| | 85 | | async Task<Page<Location>> FirstPageFunc(int? pageSizeHint) |
| | 86 | | { |
| 2 | 87 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.ListLocations"); |
| 2 | 88 | | scope.Start(); |
| | 89 | | try |
| | 90 | | { |
| 2 | 91 | | var response = await RestClient.ListLocationsAsync(subscriptionId, cancellationToken).ConfigureAwait |
| 2 | 92 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 93 | | } |
| 0 | 94 | | catch (Exception e) |
| | 95 | | { |
| 0 | 96 | | scope.Failed(e); |
| 0 | 97 | | throw; |
| | 98 | | } |
| 2 | 99 | | } |
| 2 | 100 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); |
| | 101 | | } |
| | 102 | |
|
| | 103 | | /// <summary> This operation provides all the locations that are available for resource providers; however, each |
| | 104 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 105 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 106 | | public virtual Pageable<Location> ListLocations(string subscriptionId, CancellationToken cancellationToken = def |
| | 107 | | { |
| 2 | 108 | | if (subscriptionId == null) |
| | 109 | | { |
| 0 | 110 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 111 | | } |
| | 112 | |
|
| | 113 | | Page<Location> FirstPageFunc(int? pageSizeHint) |
| | 114 | | { |
| 2 | 115 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.ListLocations"); |
| 2 | 116 | | scope.Start(); |
| | 117 | | try |
| | 118 | | { |
| 2 | 119 | | var response = RestClient.ListLocations(subscriptionId, cancellationToken); |
| 2 | 120 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 121 | | } |
| 0 | 122 | | catch (Exception e) |
| | 123 | | { |
| 0 | 124 | | scope.Failed(e); |
| 0 | 125 | | throw; |
| | 126 | | } |
| 2 | 127 | | } |
| 2 | 128 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, null); |
| | 129 | | } |
| | 130 | |
|
| | 131 | | /// <summary> Gets all subscriptions for a tenant. </summary> |
| | 132 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 133 | | public virtual AsyncPageable<Subscription> ListAsync(CancellationToken cancellationToken = default) |
| | 134 | | { |
| | 135 | | async Task<Page<Subscription>> FirstPageFunc(int? pageSizeHint) |
| | 136 | | { |
| 4 | 137 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List"); |
| 4 | 138 | | scope.Start(); |
| | 139 | | try |
| | 140 | | { |
| 4 | 141 | | var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); |
| 4 | 142 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 143 | | } |
| 0 | 144 | | catch (Exception e) |
| | 145 | | { |
| 0 | 146 | | scope.Failed(e); |
| 0 | 147 | | throw; |
| | 148 | | } |
| 4 | 149 | | } |
| | 150 | | async Task<Page<Subscription>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 151 | | { |
| 0 | 152 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List"); |
| 0 | 153 | | scope.Start(); |
| | 154 | | try |
| | 155 | | { |
| 0 | 156 | | var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false) |
| 0 | 157 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 158 | | } |
| 0 | 159 | | catch (Exception e) |
| | 160 | | { |
| 0 | 161 | | scope.Failed(e); |
| 0 | 162 | | throw; |
| | 163 | | } |
| 0 | 164 | | } |
| 4 | 165 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 166 | | } |
| | 167 | |
|
| | 168 | | /// <summary> Gets all subscriptions for a tenant. </summary> |
| | 169 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 170 | | public virtual Pageable<Subscription> List(CancellationToken cancellationToken = default) |
| | 171 | | { |
| | 172 | | Page<Subscription> FirstPageFunc(int? pageSizeHint) |
| | 173 | | { |
| 4 | 174 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List"); |
| 4 | 175 | | scope.Start(); |
| | 176 | | try |
| | 177 | | { |
| 4 | 178 | | var response = RestClient.List(cancellationToken); |
| 4 | 179 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 180 | | } |
| 0 | 181 | | catch (Exception e) |
| | 182 | | { |
| 0 | 183 | | scope.Failed(e); |
| 0 | 184 | | throw; |
| | 185 | | } |
| 4 | 186 | | } |
| | 187 | | Page<Subscription> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 188 | | { |
| 0 | 189 | | using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List"); |
| 0 | 190 | | scope.Start(); |
| | 191 | | try |
| | 192 | | { |
| 0 | 193 | | var response = RestClient.ListNextPage(nextLink, cancellationToken); |
| 0 | 194 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 195 | | } |
| 0 | 196 | | catch (Exception e) |
| | 197 | | { |
| 0 | 198 | | scope.Failed(e); |
| 0 | 199 | | throw; |
| | 200 | | } |
| 0 | 201 | | } |
| 4 | 202 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 203 | | } |
| | 204 | | } |
| | 205 | | } |