< Summary

Class:Azure.ResourceManager.Resources.SubscriptionsOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\SubscriptionsOperations.cs
Covered lines:42
Uncovered lines:36
Coverable lines:78
Total lines:205
Line coverage:53.8% (42 of 78)
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%
ListLocationsAsync(...)-63.64%50%
<ListLocationsAsync()-62.5%100%
ListLocations(...)-63.64%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
ListAsync(...)-100%100%
List(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\SubscriptionsOperations.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 Subscriptions service client. </summary>
 19    public partial class SubscriptionsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 2023        internal SubscriptionsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of SubscriptionsOperations for mocking. </summary>
 26825        protected SubscriptionsOperations()
 26        {
 26827        }
 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>
 26832        internal SubscriptionsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null
 33        {
 26834            RestClient = new SubscriptionsRestOperations(clientDiagnostics, pipeline, endpoint);
 26835            _clientDiagnostics = clientDiagnostics;
 26836            _pipeline = pipeline;
 26837        }
 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        {
 444            using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.Get");
 445            scope.Start();
 46            try
 47            {
 448                return await RestClient.GetAsync(subscriptionId, cancellationToken).ConfigureAwait(false);
 49            }
 050            catch (Exception e)
 51            {
 052                scope.Failed(e);
 053                throw;
 54            }
 455        }
 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        {
 462            using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.Get");
 463            scope.Start();
 64            try
 65            {
 466                return RestClient.Get(subscriptionId, cancellationToken);
 67            }
 068            catch (Exception e)
 69            {
 070                scope.Failed(e);
 071                throw;
 72            }
 473        }
 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        {
 280            if (subscriptionId == null)
 81            {
 082                throw new ArgumentNullException(nameof(subscriptionId));
 83            }
 84
 85            async Task<Page<Location>> FirstPageFunc(int? pageSizeHint)
 86            {
 287                using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.ListLocations");
 288                scope.Start();
 89                try
 90                {
 291                    var response = await RestClient.ListLocationsAsync(subscriptionId, cancellationToken).ConfigureAwait
 292                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 93                }
 094                catch (Exception e)
 95                {
 096                    scope.Failed(e);
 097                    throw;
 98                }
 299            }
 2100            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        {
 2108            if (subscriptionId == null)
 109            {
 0110                throw new ArgumentNullException(nameof(subscriptionId));
 111            }
 112
 113            Page<Location> FirstPageFunc(int? pageSizeHint)
 114            {
 2115                using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.ListLocations");
 2116                scope.Start();
 117                try
 118                {
 2119                    var response = RestClient.ListLocations(subscriptionId, cancellationToken);
 2120                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 121                }
 0122                catch (Exception e)
 123                {
 0124                    scope.Failed(e);
 0125                    throw;
 126                }
 2127            }
 2128            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            {
 4137                using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List");
 4138                scope.Start();
 139                try
 140                {
 4141                    var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false);
 4142                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 143                }
 0144                catch (Exception e)
 145                {
 0146                    scope.Failed(e);
 0147                    throw;
 148                }
 4149            }
 150            async Task<Page<Subscription>> NextPageFunc(string nextLink, int? pageSizeHint)
 151            {
 0152                using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List");
 0153                scope.Start();
 154                try
 155                {
 0156                    var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false)
 0157                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 158                }
 0159                catch (Exception e)
 160                {
 0161                    scope.Failed(e);
 0162                    throw;
 163                }
 0164            }
 4165            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            {
 4174                using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List");
 4175                scope.Start();
 176                try
 177                {
 4178                    var response = RestClient.List(cancellationToken);
 4179                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 180                }
 0181                catch (Exception e)
 182                {
 0183                    scope.Failed(e);
 0184                    throw;
 185                }
 4186            }
 187            Page<Subscription> NextPageFunc(string nextLink, int? pageSizeHint)
 188            {
 0189                using var scope = _clientDiagnostics.CreateScope("SubscriptionsOperations.List");
 0190                scope.Start();
 191                try
 192                {
 0193                    var response = RestClient.ListNextPage(nextLink, cancellationToken);
 0194                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 195                }
 0196                catch (Exception e)
 197                {
 0198                    scope.Failed(e);
 0199                    throw;
 200                }
 0201            }
 4202            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 203        }
 204    }
 205}