< Summary

Class:Azure.ResourceManager.Compute.AvailabilitySetsOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\AvailabilitySetsOperations.cs
Covered lines:88
Uncovered lines:74
Coverable lines:162
Total lines:424
Line coverage:54.3% (88 of 162)
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()-100%100%
CreateOrUpdate(...)-100%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%
<ListBySubscriptionAsync()-62.5%100%
<ListBySubscriptionAsync()-0%100%
ListBySubscriptionAsync(...)-100%100%
ListBySubscription(...)-100%100%
ListAsync(...)-36.84%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-36.84%50%
ListAvailableSizesAsync(...)-61.54%50%
<ListAvailableSizesAsync()-62.5%100%
ListAvailableSizes(...)-61.54%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\AvailabilitySetsOperations.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 AvailabilitySets service client. </summary>
 19    public partial class AvailabilitySetsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 22823        internal AvailabilitySetsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of AvailabilitySetsOperations for mocking. </summary>
 39625        protected AvailabilitySetsOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of AvailabilitySetsOperations. </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 AvailabilitySetsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript
 34        {
 39635            RestClient = new AvailabilitySetsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> Create or update an availability set. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="availabilitySetName"> The name of the availability set. </param>
 43        /// <param name="parameters"> Parameters supplied to the Create Availability Set operation. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<AvailabilitySet>> CreateOrUpdateAsync(string resourceGroupName, string availa
 46        {
 7447            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.CreateOrUpdate");
 7448            scope.Start();
 49            try
 50            {
 7451                return await RestClient.CreateOrUpdateAsync(resourceGroupName, availabilitySetName, parameters, cancella
 52            }
 853            catch (Exception e)
 54            {
 855                scope.Failed(e);
 856                throw;
 57            }
 6658        }
 59
 60        /// <summary> Create or update an availability set. </summary>
 61        /// <param name="resourceGroupName"> The name of the resource group. </param>
 62        /// <param name="availabilitySetName"> The name of the availability set. </param>
 63        /// <param name="parameters"> Parameters supplied to the Create Availability Set operation. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<AvailabilitySet> CreateOrUpdate(string resourceGroupName, string availabilitySetName, Av
 66        {
 7467            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.CreateOrUpdate");
 7468            scope.Start();
 69            try
 70            {
 7471                return RestClient.CreateOrUpdate(resourceGroupName, availabilitySetName, parameters, cancellationToken);
 72            }
 873            catch (Exception e)
 74            {
 875                scope.Failed(e);
 876                throw;
 77            }
 6678        }
 79
 80        /// <summary> Update an availability set. </summary>
 81        /// <param name="resourceGroupName"> The name of the resource group. </param>
 82        /// <param name="availabilitySetName"> The name of the availability set. </param>
 83        /// <param name="parameters"> Parameters supplied to the Update Availability Set operation. </param>
 84        /// <param name="cancellationToken"> The cancellation token to use. </param>
 85        public virtual async Task<Response<AvailabilitySet>> UpdateAsync(string resourceGroupName, string availabilitySe
 86        {
 287            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Update");
 288            scope.Start();
 89            try
 90            {
 291                return await RestClient.UpdateAsync(resourceGroupName, availabilitySetName, parameters, cancellationToke
 92            }
 093            catch (Exception e)
 94            {
 095                scope.Failed(e);
 096                throw;
 97            }
 298        }
 99
 100        /// <summary> Update an availability set. </summary>
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="availabilitySetName"> The name of the availability set. </param>
 103        /// <param name="parameters"> Parameters supplied to the Update Availability Set operation. </param>
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public virtual Response<AvailabilitySet> Update(string resourceGroupName, string availabilitySetName, Availabili
 106        {
 2107            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Update");
 2108            scope.Start();
 109            try
 110            {
 2111                return RestClient.Update(resourceGroupName, availabilitySetName, parameters, cancellationToken);
 112            }
 0113            catch (Exception e)
 114            {
 0115                scope.Failed(e);
 0116                throw;
 117            }
 2118        }
 119
 120        /// <summary> Delete an availability set. </summary>
 121        /// <param name="resourceGroupName"> The name of the resource group. </param>
 122        /// <param name="availabilitySetName"> The name of the availability set. </param>
 123        /// <param name="cancellationToken"> The cancellation token to use. </param>
 124        public virtual async Task<Response> DeleteAsync(string resourceGroupName, string availabilitySetName, Cancellati
 125        {
 8126            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Delete");
 8127            scope.Start();
 128            try
 129            {
 8130                return await RestClient.DeleteAsync(resourceGroupName, availabilitySetName, cancellationToken).Configure
 131            }
 0132            catch (Exception e)
 133            {
 0134                scope.Failed(e);
 0135                throw;
 136            }
 8137        }
 138
 139        /// <summary> Delete an availability set. </summary>
 140        /// <param name="resourceGroupName"> The name of the resource group. </param>
 141        /// <param name="availabilitySetName"> The name of the availability set. </param>
 142        /// <param name="cancellationToken"> The cancellation token to use. </param>
 143        public virtual Response Delete(string resourceGroupName, string availabilitySetName, CancellationToken cancellat
 144        {
 8145            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Delete");
 8146            scope.Start();
 147            try
 148            {
 8149                return RestClient.Delete(resourceGroupName, availabilitySetName, cancellationToken);
 150            }
 0151            catch (Exception e)
 152            {
 0153                scope.Failed(e);
 0154                throw;
 155            }
 8156        }
 157
 158        /// <summary> Retrieves information about an availability set. </summary>
 159        /// <param name="resourceGroupName"> The name of the resource group. </param>
 160        /// <param name="availabilitySetName"> The name of the availability set. </param>
 161        /// <param name="cancellationToken"> The cancellation token to use. </param>
 162        public virtual async Task<Response<AvailabilitySet>> GetAsync(string resourceGroupName, string availabilitySetNa
 163        {
 8164            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Get");
 8165            scope.Start();
 166            try
 167            {
 8168                return await RestClient.GetAsync(resourceGroupName, availabilitySetName, cancellationToken).ConfigureAwa
 169            }
 0170            catch (Exception e)
 171            {
 0172                scope.Failed(e);
 0173                throw;
 174            }
 8175        }
 176
 177        /// <summary> Retrieves information about an availability set. </summary>
 178        /// <param name="resourceGroupName"> The name of the resource group. </param>
 179        /// <param name="availabilitySetName"> The name of the availability set. </param>
 180        /// <param name="cancellationToken"> The cancellation token to use. </param>
 181        public virtual Response<AvailabilitySet> Get(string resourceGroupName, string availabilitySetName, CancellationT
 182        {
 8183            using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Get");
 8184            scope.Start();
 185            try
 186            {
 8187                return RestClient.Get(resourceGroupName, availabilitySetName, cancellationToken);
 188            }
 0189            catch (Exception e)
 190            {
 0191                scope.Failed(e);
 0192                throw;
 193            }
 8194        }
 195
 196        /// <summary> Lists all availability sets in a subscription. </summary>
 197        /// <param name="expand"> The expand expression to apply to the operation. </param>
 198        /// <param name="cancellationToken"> The cancellation token to use. </param>
 199        public virtual AsyncPageable<AvailabilitySet> ListBySubscriptionAsync(string expand = null, CancellationToken ca
 200        {
 201            async Task<Page<AvailabilitySet>> FirstPageFunc(int? pageSizeHint)
 202            {
 4203                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription");
 4204                scope.Start();
 205                try
 206                {
 4207                    var response = await RestClient.ListBySubscriptionAsync(expand, cancellationToken).ConfigureAwait(fa
 4208                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 209                }
 0210                catch (Exception e)
 211                {
 0212                    scope.Failed(e);
 0213                    throw;
 214                }
 4215            }
 216            async Task<Page<AvailabilitySet>> NextPageFunc(string nextLink, int? pageSizeHint)
 217            {
 0218                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription");
 0219                scope.Start();
 220                try
 221                {
 0222                    var response = await RestClient.ListBySubscriptionNextPageAsync(nextLink, expand, cancellationToken)
 0223                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 224                }
 0225                catch (Exception e)
 226                {
 0227                    scope.Failed(e);
 0228                    throw;
 229                }
 0230            }
 4231            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 232        }
 233
 234        /// <summary> Lists all availability sets in a subscription. </summary>
 235        /// <param name="expand"> The expand expression to apply to the operation. </param>
 236        /// <param name="cancellationToken"> The cancellation token to use. </param>
 237        public virtual Pageable<AvailabilitySet> ListBySubscription(string expand = null, CancellationToken cancellation
 238        {
 239            Page<AvailabilitySet> FirstPageFunc(int? pageSizeHint)
 240            {
 4241                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription");
 4242                scope.Start();
 243                try
 244                {
 4245                    var response = RestClient.ListBySubscription(expand, cancellationToken);
 4246                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 247                }
 0248                catch (Exception e)
 249                {
 0250                    scope.Failed(e);
 0251                    throw;
 252                }
 4253            }
 254            Page<AvailabilitySet> NextPageFunc(string nextLink, int? pageSizeHint)
 255            {
 0256                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription");
 0257                scope.Start();
 258                try
 259                {
 0260                    var response = RestClient.ListBySubscriptionNextPage(nextLink, expand, cancellationToken);
 0261                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 262                }
 0263                catch (Exception e)
 264                {
 0265                    scope.Failed(e);
 0266                    throw;
 267                }
 0268            }
 4269            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 270        }
 271
 272        /// <summary> Lists all availability sets in a resource group. </summary>
 273        /// <param name="resourceGroupName"> The name of the resource group. </param>
 274        /// <param name="cancellationToken"> The cancellation token to use. </param>
 275        public virtual AsyncPageable<AvailabilitySet> ListAsync(string resourceGroupName, CancellationToken cancellation
 276        {
 2277            if (resourceGroupName == null)
 278            {
 0279                throw new ArgumentNullException(nameof(resourceGroupName));
 280            }
 281
 282            async Task<Page<AvailabilitySet>> FirstPageFunc(int? pageSizeHint)
 283            {
 2284                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List");
 2285                scope.Start();
 286                try
 287                {
 2288                    var response = await RestClient.ListAsync(resourceGroupName, cancellationToken).ConfigureAwait(false
 2289                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 290                }
 0291                catch (Exception e)
 292                {
 0293                    scope.Failed(e);
 0294                    throw;
 295                }
 2296            }
 297            async Task<Page<AvailabilitySet>> NextPageFunc(string nextLink, int? pageSizeHint)
 298            {
 0299                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List");
 0300                scope.Start();
 301                try
 302                {
 0303                    var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, cancellationToken).Co
 0304                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 305                }
 0306                catch (Exception e)
 307                {
 0308                    scope.Failed(e);
 0309                    throw;
 310                }
 0311            }
 2312            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 313        }
 314
 315        /// <summary> Lists all availability sets in a resource group. </summary>
 316        /// <param name="resourceGroupName"> The name of the resource group. </param>
 317        /// <param name="cancellationToken"> The cancellation token to use. </param>
 318        public virtual Pageable<AvailabilitySet> List(string resourceGroupName, CancellationToken cancellationToken = de
 319        {
 2320            if (resourceGroupName == null)
 321            {
 0322                throw new ArgumentNullException(nameof(resourceGroupName));
 323            }
 324
 325            Page<AvailabilitySet> FirstPageFunc(int? pageSizeHint)
 326            {
 2327                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List");
 2328                scope.Start();
 329                try
 330                {
 2331                    var response = RestClient.List(resourceGroupName, cancellationToken);
 2332                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 333                }
 0334                catch (Exception e)
 335                {
 0336                    scope.Failed(e);
 0337                    throw;
 338                }
 2339            }
 340            Page<AvailabilitySet> NextPageFunc(string nextLink, int? pageSizeHint)
 341            {
 0342                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List");
 0343                scope.Start();
 344                try
 345                {
 0346                    var response = RestClient.ListNextPage(nextLink, resourceGroupName, cancellationToken);
 0347                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 348                }
 0349                catch (Exception e)
 350                {
 0351                    scope.Failed(e);
 0352                    throw;
 353                }
 0354            }
 2355            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 356        }
 357
 358        /// <summary> Lists all available virtual machine sizes that can be used to create a new virtual machine in an e
 359        /// <param name="resourceGroupName"> The name of the resource group. </param>
 360        /// <param name="availabilitySetName"> The name of the availability set. </param>
 361        /// <param name="cancellationToken"> The cancellation token to use. </param>
 362        public virtual AsyncPageable<VirtualMachineSize> ListAvailableSizesAsync(string resourceGroupName, string availa
 363        {
 16364            if (resourceGroupName == null)
 365            {
 0366                throw new ArgumentNullException(nameof(resourceGroupName));
 367            }
 16368            if (availabilitySetName == null)
 369            {
 0370                throw new ArgumentNullException(nameof(availabilitySetName));
 371            }
 372
 373            async Task<Page<VirtualMachineSize>> FirstPageFunc(int? pageSizeHint)
 374            {
 16375                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListAvailableSizes");
 16376                scope.Start();
 377                try
 378                {
 16379                    var response = await RestClient.ListAvailableSizesAsync(resourceGroupName, availabilitySetName, canc
 16380                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 381                }
 0382                catch (Exception e)
 383                {
 0384                    scope.Failed(e);
 0385                    throw;
 386                }
 16387            }
 16388            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null);
 389        }
 390
 391        /// <summary> Lists all available virtual machine sizes that can be used to create a new virtual machine in an e
 392        /// <param name="resourceGroupName"> The name of the resource group. </param>
 393        /// <param name="availabilitySetName"> The name of the availability set. </param>
 394        /// <param name="cancellationToken"> The cancellation token to use. </param>
 395        public virtual Pageable<VirtualMachineSize> ListAvailableSizes(string resourceGroupName, string availabilitySetN
 396        {
 16397            if (resourceGroupName == null)
 398            {
 0399                throw new ArgumentNullException(nameof(resourceGroupName));
 400            }
 16401            if (availabilitySetName == null)
 402            {
 0403                throw new ArgumentNullException(nameof(availabilitySetName));
 404            }
 405
 406            Page<VirtualMachineSize> FirstPageFunc(int? pageSizeHint)
 407            {
 16408                using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListAvailableSizes");
 16409                scope.Start();
 410                try
 411                {
 16412                    var response = RestClient.ListAvailableSizes(resourceGroupName, availabilitySetName, cancellationTok
 16413                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 414                }
 0415                catch (Exception e)
 416                {
 0417                    scope.Failed(e);
 0418                    throw;
 419                }
 16420            }
 16421            return PageableHelpers.CreateEnumerable(FirstPageFunc, null);
 422        }
 423    }
 424}