| | 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 Features service client. </summary> |
| | 19 | | public partial class FeaturesOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 16 | 23 | | internal FeaturesRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of FeaturesOperations for mocking. </summary> |
| 16 | 25 | | protected FeaturesOperations() |
| | 26 | | { |
| 16 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of FeaturesOperations. </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> |
| 16 | 33 | | internal FeaturesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, U |
| | 34 | | { |
| 16 | 35 | | RestClient = new FeaturesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 16 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 16 | 37 | | _pipeline = pipeline; |
| 16 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Gets the preview feature with the specified name. </summary> |
| | 41 | | /// <param name="resourceProviderNamespace"> The resource provider namespace for the feature. </param> |
| | 42 | | /// <param name="featureName"> The name of the feature to get. </param> |
| | 43 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 44 | | public virtual async Task<Response<FeatureResult>> GetAsync(string resourceProviderNamespace, string featureName |
| | 45 | | { |
| 2 | 46 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Get"); |
| 2 | 47 | | scope.Start(); |
| | 48 | | try |
| | 49 | | { |
| 2 | 50 | | return await RestClient.GetAsync(resourceProviderNamespace, featureName, cancellationToken).ConfigureAwa |
| | 51 | | } |
| 0 | 52 | | catch (Exception e) |
| | 53 | | { |
| 0 | 54 | | scope.Failed(e); |
| 0 | 55 | | throw; |
| | 56 | | } |
| 2 | 57 | | } |
| | 58 | |
|
| | 59 | | /// <summary> Gets the preview feature with the specified name. </summary> |
| | 60 | | /// <param name="resourceProviderNamespace"> The resource provider namespace for the feature. </param> |
| | 61 | | /// <param name="featureName"> The name of the feature to get. </param> |
| | 62 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 63 | | public virtual Response<FeatureResult> Get(string resourceProviderNamespace, string featureName, CancellationTok |
| | 64 | | { |
| 2 | 65 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Get"); |
| 2 | 66 | | scope.Start(); |
| | 67 | | try |
| | 68 | | { |
| 2 | 69 | | return RestClient.Get(resourceProviderNamespace, featureName, cancellationToken); |
| | 70 | | } |
| 0 | 71 | | catch (Exception e) |
| | 72 | | { |
| 0 | 73 | | scope.Failed(e); |
| 0 | 74 | | throw; |
| | 75 | | } |
| 2 | 76 | | } |
| | 77 | |
|
| | 78 | | /// <summary> Registers the preview feature for the subscription. </summary> |
| | 79 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 80 | | /// <param name="featureName"> The name of the feature to register. </param> |
| | 81 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 82 | | public virtual async Task<Response<FeatureResult>> RegisterAsync(string resourceProviderNamespace, string featur |
| | 83 | | { |
| 2 | 84 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Register"); |
| 2 | 85 | | scope.Start(); |
| | 86 | | try |
| | 87 | | { |
| 2 | 88 | | return await RestClient.RegisterAsync(resourceProviderNamespace, featureName, cancellationToken).Configu |
| | 89 | | } |
| 0 | 90 | | catch (Exception e) |
| | 91 | | { |
| 0 | 92 | | scope.Failed(e); |
| 0 | 93 | | throw; |
| | 94 | | } |
| 2 | 95 | | } |
| | 96 | |
|
| | 97 | | /// <summary> Registers the preview feature for the subscription. </summary> |
| | 98 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 99 | | /// <param name="featureName"> The name of the feature to register. </param> |
| | 100 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 101 | | public virtual Response<FeatureResult> Register(string resourceProviderNamespace, string featureName, Cancellati |
| | 102 | | { |
| 2 | 103 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Register"); |
| 2 | 104 | | scope.Start(); |
| | 105 | | try |
| | 106 | | { |
| 2 | 107 | | return RestClient.Register(resourceProviderNamespace, featureName, cancellationToken); |
| | 108 | | } |
| 0 | 109 | | catch (Exception e) |
| | 110 | | { |
| 0 | 111 | | scope.Failed(e); |
| 0 | 112 | | throw; |
| | 113 | | } |
| 2 | 114 | | } |
| | 115 | |
|
| | 116 | | /// <summary> Unregisters the preview feature for the subscription. </summary> |
| | 117 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 118 | | /// <param name="featureName"> The name of the feature to unregister. </param> |
| | 119 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 120 | | public virtual async Task<Response<FeatureResult>> UnregisterAsync(string resourceProviderNamespace, string feat |
| | 121 | | { |
| 0 | 122 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Unregister"); |
| 0 | 123 | | scope.Start(); |
| | 124 | | try |
| | 125 | | { |
| 0 | 126 | | return await RestClient.UnregisterAsync(resourceProviderNamespace, featureName, cancellationToken).Confi |
| | 127 | | } |
| 0 | 128 | | catch (Exception e) |
| | 129 | | { |
| 0 | 130 | | scope.Failed(e); |
| 0 | 131 | | throw; |
| | 132 | | } |
| 0 | 133 | | } |
| | 134 | |
|
| | 135 | | /// <summary> Unregisters the preview feature for the subscription. </summary> |
| | 136 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 137 | | /// <param name="featureName"> The name of the feature to unregister. </param> |
| | 138 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 139 | | public virtual Response<FeatureResult> Unregister(string resourceProviderNamespace, string featureName, Cancella |
| | 140 | | { |
| 0 | 141 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Unregister"); |
| 0 | 142 | | scope.Start(); |
| | 143 | | try |
| | 144 | | { |
| 0 | 145 | | return RestClient.Unregister(resourceProviderNamespace, featureName, cancellationToken); |
| | 146 | | } |
| 0 | 147 | | catch (Exception e) |
| | 148 | | { |
| 0 | 149 | | scope.Failed(e); |
| 0 | 150 | | throw; |
| | 151 | | } |
| 0 | 152 | | } |
| | 153 | |
|
| | 154 | | /// <summary> Gets all the preview features that are available through AFEC for the subscription. </summary> |
| | 155 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 156 | | public virtual AsyncPageable<FeatureResult> ListAllAsync(CancellationToken cancellationToken = default) |
| | 157 | | { |
| | 158 | | async Task<Page<FeatureResult>> FirstPageFunc(int? pageSizeHint) |
| | 159 | | { |
| 2 | 160 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll"); |
| 2 | 161 | | scope.Start(); |
| | 162 | | try |
| | 163 | | { |
| 2 | 164 | | var response = await RestClient.ListAllAsync(cancellationToken).ConfigureAwait(false); |
| 2 | 165 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 166 | | } |
| 0 | 167 | | catch (Exception e) |
| | 168 | | { |
| 0 | 169 | | scope.Failed(e); |
| 0 | 170 | | throw; |
| | 171 | | } |
| 2 | 172 | | } |
| | 173 | | async Task<Page<FeatureResult>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 174 | | { |
| 0 | 175 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll"); |
| 0 | 176 | | scope.Start(); |
| | 177 | | try |
| | 178 | | { |
| 0 | 179 | | var response = await RestClient.ListAllNextPageAsync(nextLink, cancellationToken).ConfigureAwait(fal |
| 0 | 180 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 181 | | } |
| 0 | 182 | | catch (Exception e) |
| | 183 | | { |
| 0 | 184 | | scope.Failed(e); |
| 0 | 185 | | throw; |
| | 186 | | } |
| 0 | 187 | | } |
| 2 | 188 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 189 | | } |
| | 190 | |
|
| | 191 | | /// <summary> Gets all the preview features that are available through AFEC for the subscription. </summary> |
| | 192 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 193 | | public virtual Pageable<FeatureResult> ListAll(CancellationToken cancellationToken = default) |
| | 194 | | { |
| | 195 | | Page<FeatureResult> FirstPageFunc(int? pageSizeHint) |
| | 196 | | { |
| 2 | 197 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll"); |
| 2 | 198 | | scope.Start(); |
| | 199 | | try |
| | 200 | | { |
| 2 | 201 | | var response = RestClient.ListAll(cancellationToken); |
| 2 | 202 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 203 | | } |
| 0 | 204 | | catch (Exception e) |
| | 205 | | { |
| 0 | 206 | | scope.Failed(e); |
| 0 | 207 | | throw; |
| | 208 | | } |
| 2 | 209 | | } |
| | 210 | | Page<FeatureResult> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 211 | | { |
| 0 | 212 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll"); |
| 0 | 213 | | scope.Start(); |
| | 214 | | try |
| | 215 | | { |
| 0 | 216 | | var response = RestClient.ListAllNextPage(nextLink, cancellationToken); |
| 0 | 217 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 218 | | } |
| 0 | 219 | | catch (Exception e) |
| | 220 | | { |
| 0 | 221 | | scope.Failed(e); |
| 0 | 222 | | throw; |
| | 223 | | } |
| 0 | 224 | | } |
| 2 | 225 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 226 | | } |
| | 227 | |
|
| | 228 | | /// <summary> Gets all the preview features in a provider namespace that are available through AFEC for the subs |
| | 229 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider for getting features. </para |
| | 230 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 231 | | public virtual AsyncPageable<FeatureResult> ListAsync(string resourceProviderNamespace, CancellationToken cancel |
| | 232 | | { |
| 2 | 233 | | if (resourceProviderNamespace == null) |
| | 234 | | { |
| 0 | 235 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 236 | | } |
| | 237 | |
|
| | 238 | | async Task<Page<FeatureResult>> FirstPageFunc(int? pageSizeHint) |
| | 239 | | { |
| 2 | 240 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List"); |
| 2 | 241 | | scope.Start(); |
| | 242 | | try |
| | 243 | | { |
| 2 | 244 | | var response = await RestClient.ListAsync(resourceProviderNamespace, cancellationToken).ConfigureAwa |
| 2 | 245 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 246 | | } |
| 0 | 247 | | catch (Exception e) |
| | 248 | | { |
| 0 | 249 | | scope.Failed(e); |
| 0 | 250 | | throw; |
| | 251 | | } |
| 2 | 252 | | } |
| | 253 | | async Task<Page<FeatureResult>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 254 | | { |
| 0 | 255 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List"); |
| 0 | 256 | | scope.Start(); |
| | 257 | | try |
| | 258 | | { |
| 0 | 259 | | var response = await RestClient.ListNextPageAsync(nextLink, resourceProviderNamespace, cancellationT |
| 0 | 260 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 261 | | } |
| 0 | 262 | | catch (Exception e) |
| | 263 | | { |
| 0 | 264 | | scope.Failed(e); |
| 0 | 265 | | throw; |
| | 266 | | } |
| 0 | 267 | | } |
| 2 | 268 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 269 | | } |
| | 270 | |
|
| | 271 | | /// <summary> Gets all the preview features in a provider namespace that are available through AFEC for the subs |
| | 272 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider for getting features. </para |
| | 273 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 274 | | public virtual Pageable<FeatureResult> List(string resourceProviderNamespace, CancellationToken cancellationToke |
| | 275 | | { |
| 2 | 276 | | if (resourceProviderNamespace == null) |
| | 277 | | { |
| 0 | 278 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 279 | | } |
| | 280 | |
|
| | 281 | | Page<FeatureResult> FirstPageFunc(int? pageSizeHint) |
| | 282 | | { |
| 2 | 283 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List"); |
| 2 | 284 | | scope.Start(); |
| | 285 | | try |
| | 286 | | { |
| 2 | 287 | | var response = RestClient.List(resourceProviderNamespace, cancellationToken); |
| 2 | 288 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 289 | | } |
| 0 | 290 | | catch (Exception e) |
| | 291 | | { |
| 0 | 292 | | scope.Failed(e); |
| 0 | 293 | | throw; |
| | 294 | | } |
| 2 | 295 | | } |
| | 296 | | Page<FeatureResult> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 297 | | { |
| 0 | 298 | | using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List"); |
| 0 | 299 | | scope.Start(); |
| | 300 | | try |
| | 301 | | { |
| 0 | 302 | | var response = RestClient.ListNextPage(nextLink, resourceProviderNamespace, cancellationToken); |
| 0 | 303 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 304 | | } |
| 0 | 305 | | catch (Exception e) |
| | 306 | | { |
| 0 | 307 | | scope.Failed(e); |
| 0 | 308 | | throw; |
| | 309 | | } |
| 0 | 310 | | } |
| 2 | 311 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 312 | | } |
| | 313 | | } |
| | 314 | | } |