< Summary

Class:Azure.ResourceManager.Resources.FeaturesOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\FeaturesOperations.cs
Covered lines:50
Uncovered lines:72
Coverable lines:122
Total lines:314
Line coverage:40.9% (50 of 122)
Covered branches:2
Total branches:4
Branch coverage:50% (2 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
RegisterAsync()-57.14%100%
Register(...)-57.14%100%
UnregisterAsync()-0%100%
Unregister(...)-0%100%
<ListAllAsync()-62.5%100%
<ListAllAsync()-0%100%
ListAllAsync(...)-100%100%
ListAll(...)-100%100%
ListAsync(...)-36.84%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-36.84%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\FeaturesOperations.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.ResourceManager.Resources.Models;
 15
 16namespace 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;
 1623        internal FeaturesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of FeaturesOperations for mocking. </summary>
 1625        protected FeaturesOperations()
 26        {
 1627        }
 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>
 1633        internal FeaturesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, U
 34        {
 1635            RestClient = new FeaturesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 1636            _clientDiagnostics = clientDiagnostics;
 1637            _pipeline = pipeline;
 1638        }
 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        {
 246            using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Get");
 247            scope.Start();
 48            try
 49            {
 250                return await RestClient.GetAsync(resourceProviderNamespace, featureName, cancellationToken).ConfigureAwa
 51            }
 052            catch (Exception e)
 53            {
 054                scope.Failed(e);
 055                throw;
 56            }
 257        }
 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        {
 265            using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Get");
 266            scope.Start();
 67            try
 68            {
 269                return RestClient.Get(resourceProviderNamespace, featureName, cancellationToken);
 70            }
 071            catch (Exception e)
 72            {
 073                scope.Failed(e);
 074                throw;
 75            }
 276        }
 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        {
 284            using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Register");
 285            scope.Start();
 86            try
 87            {
 288                return await RestClient.RegisterAsync(resourceProviderNamespace, featureName, cancellationToken).Configu
 89            }
 090            catch (Exception e)
 91            {
 092                scope.Failed(e);
 093                throw;
 94            }
 295        }
 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        {
 2103            using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Register");
 2104            scope.Start();
 105            try
 106            {
 2107                return RestClient.Register(resourceProviderNamespace, featureName, cancellationToken);
 108            }
 0109            catch (Exception e)
 110            {
 0111                scope.Failed(e);
 0112                throw;
 113            }
 2114        }
 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        {
 0122            using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Unregister");
 0123            scope.Start();
 124            try
 125            {
 0126                return await RestClient.UnregisterAsync(resourceProviderNamespace, featureName, cancellationToken).Confi
 127            }
 0128            catch (Exception e)
 129            {
 0130                scope.Failed(e);
 0131                throw;
 132            }
 0133        }
 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        {
 0141            using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.Unregister");
 0142            scope.Start();
 143            try
 144            {
 0145                return RestClient.Unregister(resourceProviderNamespace, featureName, cancellationToken);
 146            }
 0147            catch (Exception e)
 148            {
 0149                scope.Failed(e);
 0150                throw;
 151            }
 0152        }
 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            {
 2160                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll");
 2161                scope.Start();
 162                try
 163                {
 2164                    var response = await RestClient.ListAllAsync(cancellationToken).ConfigureAwait(false);
 2165                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 166                }
 0167                catch (Exception e)
 168                {
 0169                    scope.Failed(e);
 0170                    throw;
 171                }
 2172            }
 173            async Task<Page<FeatureResult>> NextPageFunc(string nextLink, int? pageSizeHint)
 174            {
 0175                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll");
 0176                scope.Start();
 177                try
 178                {
 0179                    var response = await RestClient.ListAllNextPageAsync(nextLink, cancellationToken).ConfigureAwait(fal
 0180                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 181                }
 0182                catch (Exception e)
 183                {
 0184                    scope.Failed(e);
 0185                    throw;
 186                }
 0187            }
 2188            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            {
 2197                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll");
 2198                scope.Start();
 199                try
 200                {
 2201                    var response = RestClient.ListAll(cancellationToken);
 2202                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 203                }
 0204                catch (Exception e)
 205                {
 0206                    scope.Failed(e);
 0207                    throw;
 208                }
 2209            }
 210            Page<FeatureResult> NextPageFunc(string nextLink, int? pageSizeHint)
 211            {
 0212                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.ListAll");
 0213                scope.Start();
 214                try
 215                {
 0216                    var response = RestClient.ListAllNextPage(nextLink, cancellationToken);
 0217                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 218                }
 0219                catch (Exception e)
 220                {
 0221                    scope.Failed(e);
 0222                    throw;
 223                }
 0224            }
 2225            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        {
 2233            if (resourceProviderNamespace == null)
 234            {
 0235                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 236            }
 237
 238            async Task<Page<FeatureResult>> FirstPageFunc(int? pageSizeHint)
 239            {
 2240                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List");
 2241                scope.Start();
 242                try
 243                {
 2244                    var response = await RestClient.ListAsync(resourceProviderNamespace, cancellationToken).ConfigureAwa
 2245                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 246                }
 0247                catch (Exception e)
 248                {
 0249                    scope.Failed(e);
 0250                    throw;
 251                }
 2252            }
 253            async Task<Page<FeatureResult>> NextPageFunc(string nextLink, int? pageSizeHint)
 254            {
 0255                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List");
 0256                scope.Start();
 257                try
 258                {
 0259                    var response = await RestClient.ListNextPageAsync(nextLink, resourceProviderNamespace, cancellationT
 0260                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 261                }
 0262                catch (Exception e)
 263                {
 0264                    scope.Failed(e);
 0265                    throw;
 266                }
 0267            }
 2268            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        {
 2276            if (resourceProviderNamespace == null)
 277            {
 0278                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 279            }
 280
 281            Page<FeatureResult> FirstPageFunc(int? pageSizeHint)
 282            {
 2283                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List");
 2284                scope.Start();
 285                try
 286                {
 2287                    var response = RestClient.List(resourceProviderNamespace, cancellationToken);
 2288                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 289                }
 0290                catch (Exception e)
 291                {
 0292                    scope.Failed(e);
 0293                    throw;
 294                }
 2295            }
 296            Page<FeatureResult> NextPageFunc(string nextLink, int? pageSizeHint)
 297            {
 0298                using var scope = _clientDiagnostics.CreateScope("FeaturesOperations.List");
 0299                scope.Start();
 300                try
 301                {
 0302                    var response = RestClient.ListNextPage(nextLink, resourceProviderNamespace, cancellationToken);
 0303                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 304                }
 0305                catch (Exception e)
 306                {
 0307                    scope.Failed(e);
 0308                    throw;
 309                }
 0310            }
 2311            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 312        }
 313    }
 314}