< Summary

Class:Azure.ResourceManager.Compute.DedicatedHostsOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\DedicatedHostsOperations.cs
Covered lines:66
Uncovered lines:90
Coverable lines:156
Total lines:400
Line coverage:42.3% (66 of 156)
Covered branches:18
Total branches:52
Branch coverage:34.6% (18 of 52)

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%
ListByHostGroupAsync(...)-38.1%50%
<ListByHostGroupAsync()-62.5%100%
<ListByHostGroupAsync()-0%100%
ListByHostGroup(...)-38.1%50%
StartCreateOrUpdateAsync()-56.25%50%
StartCreateOrUpdate(...)-56.25%50%
StartUpdateAsync()-0%0%
StartUpdate(...)-0%0%
StartDeleteAsync()-57.14%50%
StartDelete(...)-57.14%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\DedicatedHostsOperations.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 DedicatedHosts service client. </summary>
 19    public partial class DedicatedHostsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 2423        internal DedicatedHostsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of DedicatedHostsOperations for mocking. </summary>
 39625        protected DedicatedHostsOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of DedicatedHostsOperations. </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 DedicatedHostsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 34        {
 39635            RestClient = new DedicatedHostsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> Retrieves information about a dedicated host. </summary>
 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="hostName"> The name of the dedicated host. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<DedicatedHost>> GetAsync(string resourceGroupName, string hostGroupName, stri
 46        {
 247            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.Get");
 248            scope.Start();
 49            try
 50            {
 251                return await RestClient.GetAsync(resourceGroupName, hostGroupName, hostName, cancellationToken).Configur
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 258        }
 59
 60        /// <summary> Retrieves information about a dedicated host. </summary>
 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="hostName"> The name of the dedicated host. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<DedicatedHost> Get(string resourceGroupName, string hostGroupName, string hostName, Canc
 66        {
 267            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.Get");
 268            scope.Start();
 69            try
 70            {
 271                return RestClient.Get(resourceGroupName, hostGroupName, hostName, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 278        }
 79
 80        /// <summary> Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property 
 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="cancellationToken"> The cancellation token to use. </param>
 84        public virtual AsyncPageable<DedicatedHost> ListByHostGroupAsync(string resourceGroupName, string hostGroupName,
 85        {
 286            if (resourceGroupName == null)
 87            {
 088                throw new ArgumentNullException(nameof(resourceGroupName));
 89            }
 290            if (hostGroupName == null)
 91            {
 092                throw new ArgumentNullException(nameof(hostGroupName));
 93            }
 94
 95            async Task<Page<DedicatedHost>> FirstPageFunc(int? pageSizeHint)
 96            {
 297                using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.ListByHostGroup");
 298                scope.Start();
 99                try
 100                {
 2101                    var response = await RestClient.ListByHostGroupAsync(resourceGroupName, hostGroupName, cancellationT
 2102                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 103                }
 0104                catch (Exception e)
 105                {
 0106                    scope.Failed(e);
 0107                    throw;
 108                }
 2109            }
 110            async Task<Page<DedicatedHost>> NextPageFunc(string nextLink, int? pageSizeHint)
 111            {
 0112                using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.ListByHostGroup");
 0113                scope.Start();
 114                try
 115                {
 0116                    var response = await RestClient.ListByHostGroupNextPageAsync(nextLink, resourceGroupName, hostGroupN
 0117                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 118                }
 0119                catch (Exception e)
 120                {
 0121                    scope.Failed(e);
 0122                    throw;
 123                }
 0124            }
 2125            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 126        }
 127
 128        /// <summary> Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property 
 129        /// <param name="resourceGroupName"> The name of the resource group. </param>
 130        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 131        /// <param name="cancellationToken"> The cancellation token to use. </param>
 132        public virtual Pageable<DedicatedHost> ListByHostGroup(string resourceGroupName, string hostGroupName, Cancellat
 133        {
 2134            if (resourceGroupName == null)
 135            {
 0136                throw new ArgumentNullException(nameof(resourceGroupName));
 137            }
 2138            if (hostGroupName == null)
 139            {
 0140                throw new ArgumentNullException(nameof(hostGroupName));
 141            }
 142
 143            Page<DedicatedHost> FirstPageFunc(int? pageSizeHint)
 144            {
 2145                using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.ListByHostGroup");
 2146                scope.Start();
 147                try
 148                {
 2149                    var response = RestClient.ListByHostGroup(resourceGroupName, hostGroupName, cancellationToken);
 2150                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 151                }
 0152                catch (Exception e)
 153                {
 0154                    scope.Failed(e);
 0155                    throw;
 156                }
 2157            }
 158            Page<DedicatedHost> NextPageFunc(string nextLink, int? pageSizeHint)
 159            {
 0160                using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.ListByHostGroup");
 0161                scope.Start();
 162                try
 163                {
 0164                    var response = RestClient.ListByHostGroupNextPage(nextLink, resourceGroupName, hostGroupName, cancel
 0165                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 166                }
 0167                catch (Exception e)
 168                {
 0169                    scope.Failed(e);
 0170                    throw;
 171                }
 0172            }
 2173            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 174        }
 175
 176        /// <summary> Create or update a dedicated host . </summary>
 177        /// <param name="resourceGroupName"> The name of the resource group. </param>
 178        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 179        /// <param name="hostName"> The name of the dedicated host . </param>
 180        /// <param name="parameters"> Parameters supplied to the Create Dedicated Host. </param>
 181        /// <param name="cancellationToken"> The cancellation token to use. </param>
 182        public virtual async Task<DedicatedHostsCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupNa
 183        {
 2184            if (resourceGroupName == null)
 185            {
 0186                throw new ArgumentNullException(nameof(resourceGroupName));
 187            }
 2188            if (hostGroupName == null)
 189            {
 0190                throw new ArgumentNullException(nameof(hostGroupName));
 191            }
 2192            if (hostName == null)
 193            {
 0194                throw new ArgumentNullException(nameof(hostName));
 195            }
 2196            if (parameters == null)
 197            {
 0198                throw new ArgumentNullException(nameof(parameters));
 199            }
 200
 2201            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.StartCreateOrUpdate");
 2202            scope.Start();
 203            try
 204            {
 2205                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, hostGroupName, hostName, 
 2206                return new DedicatedHostsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateO
 207            }
 0208            catch (Exception e)
 209            {
 0210                scope.Failed(e);
 0211                throw;
 212            }
 2213        }
 214
 215        /// <summary> Create or update a dedicated host . </summary>
 216        /// <param name="resourceGroupName"> The name of the resource group. </param>
 217        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 218        /// <param name="hostName"> The name of the dedicated host . </param>
 219        /// <param name="parameters"> Parameters supplied to the Create Dedicated Host. </param>
 220        /// <param name="cancellationToken"> The cancellation token to use. </param>
 221        public virtual DedicatedHostsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string hostGr
 222        {
 2223            if (resourceGroupName == null)
 224            {
 0225                throw new ArgumentNullException(nameof(resourceGroupName));
 226            }
 2227            if (hostGroupName == null)
 228            {
 0229                throw new ArgumentNullException(nameof(hostGroupName));
 230            }
 2231            if (hostName == null)
 232            {
 0233                throw new ArgumentNullException(nameof(hostName));
 234            }
 2235            if (parameters == null)
 236            {
 0237                throw new ArgumentNullException(nameof(parameters));
 238            }
 239
 2240            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.StartCreateOrUpdate");
 2241            scope.Start();
 242            try
 243            {
 2244                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, hostGroupName, hostName, parameters,
 2245                return new DedicatedHostsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateO
 246            }
 0247            catch (Exception e)
 248            {
 0249                scope.Failed(e);
 0250                throw;
 251            }
 2252        }
 253
 254        /// <summary> Update an dedicated host . </summary>
 255        /// <param name="resourceGroupName"> The name of the resource group. </param>
 256        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 257        /// <param name="hostName"> The name of the dedicated host . </param>
 258        /// <param name="parameters"> Parameters supplied to the Update Dedicated Host operation. </param>
 259        /// <param name="cancellationToken"> The cancellation token to use. </param>
 260        public virtual async Task<DedicatedHostsUpdateOperation> StartUpdateAsync(string resourceGroupName, string hostG
 261        {
 0262            if (resourceGroupName == null)
 263            {
 0264                throw new ArgumentNullException(nameof(resourceGroupName));
 265            }
 0266            if (hostGroupName == null)
 267            {
 0268                throw new ArgumentNullException(nameof(hostGroupName));
 269            }
 0270            if (hostName == null)
 271            {
 0272                throw new ArgumentNullException(nameof(hostName));
 273            }
 0274            if (parameters == null)
 275            {
 0276                throw new ArgumentNullException(nameof(parameters));
 277            }
 278
 0279            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.StartUpdate");
 0280            scope.Start();
 281            try
 282            {
 0283                var originalResponse = await RestClient.UpdateAsync(resourceGroupName, hostGroupName, hostName, paramete
 0284                return new DedicatedHostsUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(r
 285            }
 0286            catch (Exception e)
 287            {
 0288                scope.Failed(e);
 0289                throw;
 290            }
 0291        }
 292
 293        /// <summary> Update an dedicated host . </summary>
 294        /// <param name="resourceGroupName"> The name of the resource group. </param>
 295        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 296        /// <param name="hostName"> The name of the dedicated host . </param>
 297        /// <param name="parameters"> Parameters supplied to the Update Dedicated Host operation. </param>
 298        /// <param name="cancellationToken"> The cancellation token to use. </param>
 299        public virtual DedicatedHostsUpdateOperation StartUpdate(string resourceGroupName, string hostGroupName, string 
 300        {
 0301            if (resourceGroupName == null)
 302            {
 0303                throw new ArgumentNullException(nameof(resourceGroupName));
 304            }
 0305            if (hostGroupName == null)
 306            {
 0307                throw new ArgumentNullException(nameof(hostGroupName));
 308            }
 0309            if (hostName == null)
 310            {
 0311                throw new ArgumentNullException(nameof(hostName));
 312            }
 0313            if (parameters == null)
 314            {
 0315                throw new ArgumentNullException(nameof(parameters));
 316            }
 317
 0318            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.StartUpdate");
 0319            scope.Start();
 320            try
 321            {
 0322                var originalResponse = RestClient.Update(resourceGroupName, hostGroupName, hostName, parameters, cancell
 0323                return new DedicatedHostsUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(r
 324            }
 0325            catch (Exception e)
 326            {
 0327                scope.Failed(e);
 0328                throw;
 329            }
 0330        }
 331
 332        /// <summary> Delete a dedicated host. </summary>
 333        /// <param name="resourceGroupName"> The name of the resource group. </param>
 334        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 335        /// <param name="hostName"> The name of the dedicated host. </param>
 336        /// <param name="cancellationToken"> The cancellation token to use. </param>
 337        public virtual async Task<DedicatedHostsDeleteOperation> StartDeleteAsync(string resourceGroupName, string hostG
 338        {
 2339            if (resourceGroupName == null)
 340            {
 0341                throw new ArgumentNullException(nameof(resourceGroupName));
 342            }
 2343            if (hostGroupName == null)
 344            {
 0345                throw new ArgumentNullException(nameof(hostGroupName));
 346            }
 2347            if (hostName == null)
 348            {
 0349                throw new ArgumentNullException(nameof(hostName));
 350            }
 351
 2352            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.StartDelete");
 2353            scope.Start();
 354            try
 355            {
 2356                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, hostGroupName, hostName, cancella
 2357                return new DedicatedHostsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r
 358            }
 0359            catch (Exception e)
 360            {
 0361                scope.Failed(e);
 0362                throw;
 363            }
 2364        }
 365
 366        /// <summary> Delete a dedicated host. </summary>
 367        /// <param name="resourceGroupName"> The name of the resource group. </param>
 368        /// <param name="hostGroupName"> The name of the dedicated host group. </param>
 369        /// <param name="hostName"> The name of the dedicated host. </param>
 370        /// <param name="cancellationToken"> The cancellation token to use. </param>
 371        public virtual DedicatedHostsDeleteOperation StartDelete(string resourceGroupName, string hostGroupName, string 
 372        {
 2373            if (resourceGroupName == null)
 374            {
 0375                throw new ArgumentNullException(nameof(resourceGroupName));
 376            }
 2377            if (hostGroupName == null)
 378            {
 0379                throw new ArgumentNullException(nameof(hostGroupName));
 380            }
 2381            if (hostName == null)
 382            {
 0383                throw new ArgumentNullException(nameof(hostName));
 384            }
 385
 2386            using var scope = _clientDiagnostics.CreateScope("DedicatedHostsOperations.StartDelete");
 2387            scope.Start();
 388            try
 389            {
 2390                var originalResponse = RestClient.Delete(resourceGroupName, hostGroupName, hostName, cancellationToken);
 2391                return new DedicatedHostsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r
 392            }
 0393            catch (Exception e)
 394            {
 0395                scope.Failed(e);
 0396                throw;
 397            }
 2398        }
 399    }
 400}