< Summary

Class:Azure.ResourceManager.Compute.DedicatedHostGroupsOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\DedicatedHostGroupsOperations.cs
Covered lines:66
Uncovered lines:70
Coverable lines:136
Total lines:356
Line coverage:48.5% (66 of 136)
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%
CreateOrUpdateAsync()-57.14%100%
CreateOrUpdate(...)-57.14%100%
UpdateAsync()-57.14%100%
Update(...)-57.14%100%
DeleteAsync()-57.14%100%
Delete(...)-57.14%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
ListByResourceGroupAsync(...)-36.84%50%
<ListByResourceGroupAsync()-62.5%100%
<ListByResourceGroupAsync()-0%100%
ListByResourceGroup(...)-36.84%50%
<ListBySubscriptionAsync()-62.5%100%
<ListBySubscriptionAsync()-0%100%
ListBySubscriptionAsync(...)-100%100%
ListBySubscription(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\DedicatedHostGroupsOperations.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.Compute.Models;
 15
 16namespace Azure.ResourceManager.Compute
 17{
 18    /// <summary> The DedicatedHostGroups service client. </summary>
 19    public partial class DedicatedHostGroupsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 2823        internal DedicatedHostGroupsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of DedicatedHostGroupsOperations for mocking. </summary>
 39625        protected DedicatedHostGroupsOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of DedicatedHostGroupsOperations. </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 which uniquely identify Microsoft Azure subscription.
 32        /// <param name="endpoint"> server parameter. </param>
 39633        internal DedicatedHostGroupsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscr
 34        {
 39635            RestClient = new DedicatedHostGroupsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups p
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 43        /// <param name="parameters"> Parameters supplied to the Create Dedicated Host Group. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<DedicatedHostGroup>> CreateOrUpdateAsync(string resourceGroupName, string hos
 46        {
 247            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.CreateOrUpdate");
 248            scope.Start();
 49            try
 50            {
 251                return await RestClient.CreateOrUpdateAsync(resourceGroupName, hostGroupName, parameters, cancellationTo
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 258        }
 59
 60        /// <summary> Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups p
 61        /// <param name="resourceGroupName"> The name of the resource group. </param>
 62        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 63        /// <param name="parameters"> Parameters supplied to the Create Dedicated Host Group. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<DedicatedHostGroup> CreateOrUpdate(string resourceGroupName, string hostGroupName, Dedic
 66        {
 267            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.CreateOrUpdate");
 268            scope.Start();
 69            try
 70            {
 271                return RestClient.CreateOrUpdate(resourceGroupName, hostGroupName, parameters, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 278        }
 79
 80        /// <summary> Update an dedicated host group. </summary>
 81        /// <param name="resourceGroupName"> The name of the resource group. </param>
 82        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 83        /// <param name="parameters"> Parameters supplied to the Update Dedicated Host Group operation. </param>
 84        /// <param name="cancellationToken"> The cancellation token to use. </param>
 85        public virtual async Task<Response<DedicatedHostGroup>> UpdateAsync(string resourceGroupName, string hostGroupNa
 86        {
 287            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.Update");
 288            scope.Start();
 89            try
 90            {
 291                return await RestClient.UpdateAsync(resourceGroupName, hostGroupName, parameters, cancellationToken).Con
 92            }
 093            catch (Exception e)
 94            {
 095                scope.Failed(e);
 096                throw;
 97            }
 298        }
 99
 100        /// <summary> Update an dedicated host group. </summary>
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 103        /// <param name="parameters"> Parameters supplied to the Update Dedicated Host Group operation. </param>
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public virtual Response<DedicatedHostGroup> Update(string resourceGroupName, string hostGroupName, DedicatedHost
 106        {
 2107            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.Update");
 2108            scope.Start();
 109            try
 110            {
 2111                return RestClient.Update(resourceGroupName, hostGroupName, parameters, cancellationToken);
 112            }
 0113            catch (Exception e)
 114            {
 0115                scope.Failed(e);
 0116                throw;
 117            }
 2118        }
 119
 120        /// <summary> Delete a dedicated host group. </summary>
 121        /// <param name="resourceGroupName"> The name of the resource group. </param>
 122        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 123        /// <param name="cancellationToken"> The cancellation token to use. </param>
 124        public virtual async Task<Response> DeleteAsync(string resourceGroupName, string hostGroupName, CancellationToke
 125        {
 2126            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.Delete");
 2127            scope.Start();
 128            try
 129            {
 2130                return await RestClient.DeleteAsync(resourceGroupName, hostGroupName, cancellationToken).ConfigureAwait(
 131            }
 0132            catch (Exception e)
 133            {
 0134                scope.Failed(e);
 0135                throw;
 136            }
 2137        }
 138
 139        /// <summary> Delete a dedicated host group. </summary>
 140        /// <param name="resourceGroupName"> The name of the resource group. </param>
 141        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 142        /// <param name="cancellationToken"> The cancellation token to use. </param>
 143        public virtual Response Delete(string resourceGroupName, string hostGroupName, CancellationToken cancellationTok
 144        {
 2145            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.Delete");
 2146            scope.Start();
 147            try
 148            {
 2149                return RestClient.Delete(resourceGroupName, hostGroupName, cancellationToken);
 150            }
 0151            catch (Exception e)
 152            {
 0153                scope.Failed(e);
 0154                throw;
 155            }
 2156        }
 157
 158        /// <summary> Retrieves information about a dedicated host group. </summary>
 159        /// <param name="resourceGroupName"> The name of the resource group. </param>
 160        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 161        /// <param name="cancellationToken"> The cancellation token to use. </param>
 162        public virtual async Task<Response<DedicatedHostGroup>> GetAsync(string resourceGroupName, string hostGroupName,
 163        {
 4164            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.Get");
 4165            scope.Start();
 166            try
 167            {
 4168                return await RestClient.GetAsync(resourceGroupName, hostGroupName, cancellationToken).ConfigureAwait(fal
 169            }
 0170            catch (Exception e)
 171            {
 0172                scope.Failed(e);
 0173                throw;
 174            }
 4175        }
 176
 177        /// <summary> Retrieves information about a dedicated host group. </summary>
 178        /// <param name="resourceGroupName"> The name of the resource group. </param>
 179        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 180        /// <param name="cancellationToken"> The cancellation token to use. </param>
 181        public virtual Response<DedicatedHostGroup> Get(string resourceGroupName, string hostGroupName, CancellationToke
 182        {
 4183            using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.Get");
 4184            scope.Start();
 185            try
 186            {
 4187                return RestClient.Get(resourceGroupName, hostGroupName, cancellationToken);
 188            }
 0189            catch (Exception e)
 190            {
 0191                scope.Failed(e);
 0192                throw;
 193            }
 4194        }
 195
 196        /// <summary> Lists all of the dedicated host groups in the specified resource group. Use the nextLink property 
 197        /// <param name="resourceGroupName"> The name of the resource group. </param>
 198        /// <param name="cancellationToken"> The cancellation token to use. </param>
 199        public virtual AsyncPageable<DedicatedHostGroup> ListByResourceGroupAsync(string resourceGroupName, Cancellation
 200        {
 2201            if (resourceGroupName == null)
 202            {
 0203                throw new ArgumentNullException(nameof(resourceGroupName));
 204            }
 205
 206            async Task<Page<DedicatedHostGroup>> FirstPageFunc(int? pageSizeHint)
 207            {
 2208                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListByResourceGroup");
 2209                scope.Start();
 210                try
 211                {
 2212                    var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).Confi
 2213                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 214                }
 0215                catch (Exception e)
 216                {
 0217                    scope.Failed(e);
 0218                    throw;
 219                }
 2220            }
 221            async Task<Page<DedicatedHostGroup>> NextPageFunc(string nextLink, int? pageSizeHint)
 222            {
 0223                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListByResourceGroup");
 0224                scope.Start();
 225                try
 226                {
 0227                    var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancel
 0228                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 229                }
 0230                catch (Exception e)
 231                {
 0232                    scope.Failed(e);
 0233                    throw;
 234                }
 0235            }
 2236            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 237        }
 238
 239        /// <summary> Lists all of the dedicated host groups in the specified resource group. Use the nextLink property 
 240        /// <param name="resourceGroupName"> The name of the resource group. </param>
 241        /// <param name="cancellationToken"> The cancellation token to use. </param>
 242        public virtual Pageable<DedicatedHostGroup> ListByResourceGroup(string resourceGroupName, CancellationToken canc
 243        {
 2244            if (resourceGroupName == null)
 245            {
 0246                throw new ArgumentNullException(nameof(resourceGroupName));
 247            }
 248
 249            Page<DedicatedHostGroup> FirstPageFunc(int? pageSizeHint)
 250            {
 2251                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListByResourceGroup");
 2252                scope.Start();
 253                try
 254                {
 2255                    var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken);
 2256                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 257                }
 0258                catch (Exception e)
 259                {
 0260                    scope.Failed(e);
 0261                    throw;
 262                }
 2263            }
 264            Page<DedicatedHostGroup> NextPageFunc(string nextLink, int? pageSizeHint)
 265            {
 0266                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListByResourceGroup");
 0267                scope.Start();
 268                try
 269                {
 0270                    var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken
 0271                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 272                }
 0273                catch (Exception e)
 274                {
 0275                    scope.Failed(e);
 0276                    throw;
 277                }
 0278            }
 2279            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 280        }
 281
 282        /// <summary> Lists all of the dedicated host groups in the subscription. Use the nextLink property in the respo
 283        /// <param name="cancellationToken"> The cancellation token to use. </param>
 284        public virtual AsyncPageable<DedicatedHostGroup> ListBySubscriptionAsync(CancellationToken cancellationToken = d
 285        {
 286            async Task<Page<DedicatedHostGroup>> FirstPageFunc(int? pageSizeHint)
 287            {
 2288                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListBySubscription");
 2289                scope.Start();
 290                try
 291                {
 2292                    var response = await RestClient.ListBySubscriptionAsync(cancellationToken).ConfigureAwait(false);
 2293                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 294                }
 0295                catch (Exception e)
 296                {
 0297                    scope.Failed(e);
 0298                    throw;
 299                }
 2300            }
 301            async Task<Page<DedicatedHostGroup>> NextPageFunc(string nextLink, int? pageSizeHint)
 302            {
 0303                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListBySubscription");
 0304                scope.Start();
 305                try
 306                {
 0307                    var response = await RestClient.ListBySubscriptionNextPageAsync(nextLink, cancellationToken).Configu
 0308                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 309                }
 0310                catch (Exception e)
 311                {
 0312                    scope.Failed(e);
 0313                    throw;
 314                }
 0315            }
 2316            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 317        }
 318
 319        /// <summary> Lists all of the dedicated host groups in the subscription. Use the nextLink property in the respo
 320        /// <param name="cancellationToken"> The cancellation token to use. </param>
 321        public virtual Pageable<DedicatedHostGroup> ListBySubscription(CancellationToken cancellationToken = default)
 322        {
 323            Page<DedicatedHostGroup> FirstPageFunc(int? pageSizeHint)
 324            {
 2325                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListBySubscription");
 2326                scope.Start();
 327                try
 328                {
 2329                    var response = RestClient.ListBySubscription(cancellationToken);
 2330                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 331                }
 0332                catch (Exception e)
 333                {
 0334                    scope.Failed(e);
 0335                    throw;
 336                }
 2337            }
 338            Page<DedicatedHostGroup> NextPageFunc(string nextLink, int? pageSizeHint)
 339            {
 0340                using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.ListBySubscription");
 0341                scope.Start();
 342                try
 343                {
 0344                    var response = RestClient.ListBySubscriptionNextPage(nextLink, cancellationToken);
 0345                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 346                }
 0347                catch (Exception e)
 348                {
 0349                    scope.Failed(e);
 0350                    throw;
 351                }
 0352            }
 2353            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 354        }
 355    }
 356}