< Summary

Class:Azure.ResourceManager.EventHubs.ConsumerGroupsOperations
Assembly:Azure.ResourceManager.EventHubs
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\ConsumerGroupsOperations.cs
Covered lines:60
Uncovered lines:36
Coverable lines:96
Total lines:278
Line coverage:62.5% (60 of 96)
Covered branches:6
Total branches:12
Branch coverage:50% (6 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
CreateOrUpdateAsync()-57.14%100%
CreateOrUpdate(...)-57.14%100%
DeleteAsync()-57.14%100%
Delete(...)-57.14%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
ListByEventHubAsync(...)-60.87%50%
<ListByEventHubAsync()-62.5%100%
<ListByEventHubAsync()-62.5%100%
ListByEventHub(...)-60.87%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\ConsumerGroupsOperations.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.EventHubs.Models;
 15
 16namespace Azure.ResourceManager.EventHubs
 17{
 18    /// <summary> The ConsumerGroups service client. </summary>
 19    public partial class ConsumerGroupsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 10023        internal ConsumerGroupsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of ConsumerGroupsOperations for mocking. </summary>
 4825        protected ConsumerGroupsOperations()
 26        {
 4827        }
 28        /// <summary> Initializes a new instance of ConsumerGroupsOperations. </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>
 4833        internal ConsumerGroupsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 34        {
 4835            RestClient = new ConsumerGroupsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 4836            _clientDiagnostics = clientDiagnostics;
 4837            _pipeline = pipeline;
 4838        }
 39
 40        /// <summary> Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. </summary
 41        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 42        /// <param name="namespaceName"> The Namespace name. </param>
 43        /// <param name="eventHubName"> The Event Hub name. </param>
 44        /// <param name="consumerGroupName"> The consumer group name. </param>
 45        /// <param name="parameters"> Parameters supplied to create or update a consumer group resource. </param>
 46        /// <param name="cancellationToken"> The cancellation token to use. </param>
 47        public virtual async Task<Response<ConsumerGroup>> CreateOrUpdateAsync(string resourceGroupName, string namespac
 48        {
 2849            using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.CreateOrUpdate");
 2850            scope.Start();
 51            try
 52            {
 2853                return await RestClient.CreateOrUpdateAsync(resourceGroupName, namespaceName, eventHubName, consumerGrou
 54            }
 055            catch (Exception e)
 56            {
 057                scope.Failed(e);
 058                throw;
 59            }
 2860        }
 61
 62        /// <summary> Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. </summary
 63        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 64        /// <param name="namespaceName"> The Namespace name. </param>
 65        /// <param name="eventHubName"> The Event Hub name. </param>
 66        /// <param name="consumerGroupName"> The consumer group name. </param>
 67        /// <param name="parameters"> Parameters supplied to create or update a consumer group resource. </param>
 68        /// <param name="cancellationToken"> The cancellation token to use. </param>
 69        public virtual Response<ConsumerGroup> CreateOrUpdate(string resourceGroupName, string namespaceName, string eve
 70        {
 2871            using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.CreateOrUpdate");
 2872            scope.Start();
 73            try
 74            {
 2875                return RestClient.CreateOrUpdate(resourceGroupName, namespaceName, eventHubName, consumerGroupName, para
 76            }
 077            catch (Exception e)
 78            {
 079                scope.Failed(e);
 080                throw;
 81            }
 2882        }
 83
 84        /// <summary> Deletes a consumer group from the specified Event Hub and resource group. </summary>
 85        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 86        /// <param name="namespaceName"> The Namespace name. </param>
 87        /// <param name="eventHubName"> The Event Hub name. </param>
 88        /// <param name="consumerGroupName"> The consumer group name. </param>
 89        /// <param name="cancellationToken"> The cancellation token to use. </param>
 90        public virtual async Task<Response> DeleteAsync(string resourceGroupName, string namespaceName, string eventHubN
 91        {
 492            using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Delete");
 493            scope.Start();
 94            try
 95            {
 496                return await RestClient.DeleteAsync(resourceGroupName, namespaceName, eventHubName, consumerGroupName, c
 97            }
 098            catch (Exception e)
 99            {
 0100                scope.Failed(e);
 0101                throw;
 102            }
 4103        }
 104
 105        /// <summary> Deletes a consumer group from the specified Event Hub and resource group. </summary>
 106        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 107        /// <param name="namespaceName"> The Namespace name. </param>
 108        /// <param name="eventHubName"> The Event Hub name. </param>
 109        /// <param name="consumerGroupName"> The consumer group name. </param>
 110        /// <param name="cancellationToken"> The cancellation token to use. </param>
 111        public virtual Response Delete(string resourceGroupName, string namespaceName, string eventHubName, string consu
 112        {
 4113            using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Delete");
 4114            scope.Start();
 115            try
 116            {
 4117                return RestClient.Delete(resourceGroupName, namespaceName, eventHubName, consumerGroupName, cancellation
 118            }
 0119            catch (Exception e)
 120            {
 0121                scope.Failed(e);
 0122                throw;
 123            }
 4124        }
 125
 126        /// <summary> Gets a description for the specified consumer group. </summary>
 127        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 128        /// <param name="namespaceName"> The Namespace name. </param>
 129        /// <param name="eventHubName"> The Event Hub name. </param>
 130        /// <param name="consumerGroupName"> The consumer group name. </param>
 131        /// <param name="cancellationToken"> The cancellation token to use. </param>
 132        public virtual async Task<Response<ConsumerGroup>> GetAsync(string resourceGroupName, string namespaceName, stri
 133        {
 8134            using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Get");
 8135            scope.Start();
 136            try
 137            {
 8138                return await RestClient.GetAsync(resourceGroupName, namespaceName, eventHubName, consumerGroupName, canc
 139            }
 0140            catch (Exception e)
 141            {
 0142                scope.Failed(e);
 0143                throw;
 144            }
 8145        }
 146
 147        /// <summary> Gets a description for the specified consumer group. </summary>
 148        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 149        /// <param name="namespaceName"> The Namespace name. </param>
 150        /// <param name="eventHubName"> The Event Hub name. </param>
 151        /// <param name="consumerGroupName"> The consumer group name. </param>
 152        /// <param name="cancellationToken"> The cancellation token to use. </param>
 153        public virtual Response<ConsumerGroup> Get(string resourceGroupName, string namespaceName, string eventHubName, 
 154        {
 8155            using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Get");
 8156            scope.Start();
 157            try
 158            {
 8159                return RestClient.Get(resourceGroupName, namespaceName, eventHubName, consumerGroupName, cancellationTok
 160            }
 0161            catch (Exception e)
 162            {
 0163                scope.Failed(e);
 0164                throw;
 165            }
 8166        }
 167
 168        /// <summary> Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists
 169        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 170        /// <param name="namespaceName"> The Namespace name. </param>
 171        /// <param name="eventHubName"> The Event Hub name. </param>
 172        /// <param name="skip"> Skip is only used if a previous operation returned a partial result. If a previous respo
 173        /// <param name="top"> May be used to limit the number of results to the most recent N usageDetails. </param>
 174        /// <param name="cancellationToken"> The cancellation token to use. </param>
 175        public virtual AsyncPageable<ConsumerGroup> ListByEventHubAsync(string resourceGroupName, string namespaceName, 
 176        {
 8177            if (resourceGroupName == null)
 178            {
 0179                throw new ArgumentNullException(nameof(resourceGroupName));
 180            }
 8181            if (namespaceName == null)
 182            {
 0183                throw new ArgumentNullException(nameof(namespaceName));
 184            }
 8185            if (eventHubName == null)
 186            {
 0187                throw new ArgumentNullException(nameof(eventHubName));
 188            }
 189
 190            async Task<Page<ConsumerGroup>> FirstPageFunc(int? pageSizeHint)
 191            {
 8192                using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub");
 8193                scope.Start();
 194                try
 195                {
 8196                    var response = await RestClient.ListByEventHubAsync(resourceGroupName, namespaceName, eventHubName, 
 8197                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 198                }
 0199                catch (Exception e)
 200                {
 0201                    scope.Failed(e);
 0202                    throw;
 203                }
 8204            }
 205            async Task<Page<ConsumerGroup>> NextPageFunc(string nextLink, int? pageSizeHint)
 206            {
 2207                using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub");
 2208                scope.Start();
 209                try
 210                {
 2211                    var response = await RestClient.ListByEventHubNextPageAsync(nextLink, resourceGroupName, namespaceNa
 2212                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 213                }
 0214                catch (Exception e)
 215                {
 0216                    scope.Failed(e);
 0217                    throw;
 218                }
 2219            }
 8220            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 221        }
 222
 223        /// <summary> Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists
 224        /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param>
 225        /// <param name="namespaceName"> The Namespace name. </param>
 226        /// <param name="eventHubName"> The Event Hub name. </param>
 227        /// <param name="skip"> Skip is only used if a previous operation returned a partial result. If a previous respo
 228        /// <param name="top"> May be used to limit the number of results to the most recent N usageDetails. </param>
 229        /// <param name="cancellationToken"> The cancellation token to use. </param>
 230        public virtual Pageable<ConsumerGroup> ListByEventHub(string resourceGroupName, string namespaceName, string eve
 231        {
 8232            if (resourceGroupName == null)
 233            {
 0234                throw new ArgumentNullException(nameof(resourceGroupName));
 235            }
 8236            if (namespaceName == null)
 237            {
 0238                throw new ArgumentNullException(nameof(namespaceName));
 239            }
 8240            if (eventHubName == null)
 241            {
 0242                throw new ArgumentNullException(nameof(eventHubName));
 243            }
 244
 245            Page<ConsumerGroup> FirstPageFunc(int? pageSizeHint)
 246            {
 8247                using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub");
 8248                scope.Start();
 249                try
 250                {
 8251                    var response = RestClient.ListByEventHub(resourceGroupName, namespaceName, eventHubName, skip, top, 
 8252                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 253                }
 0254                catch (Exception e)
 255                {
 0256                    scope.Failed(e);
 0257                    throw;
 258                }
 8259            }
 260            Page<ConsumerGroup> NextPageFunc(string nextLink, int? pageSizeHint)
 261            {
 2262                using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub");
 2263                scope.Start();
 264                try
 265                {
 2266                    var response = RestClient.ListByEventHubNextPage(nextLink, resourceGroupName, namespaceName, eventHu
 2267                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 268                }
 0269                catch (Exception e)
 270                {
 0271                    scope.Failed(e);
 0272                    throw;
 273                }
 2274            }
 8275            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 276        }
 277    }
 278}