< Summary

Class:Azure.ResourceManager.Compute.GalleriesOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\GalleriesOperations.cs
Covered lines:72
Uncovered lines:102
Coverable lines:174
Total lines:432
Line coverage:41.3% (72 of 174)
Covered branches:12
Total branches:36
Branch coverage:33.3% (12 of 36)

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%
ListByResourceGroupAsync(...)-36.84%50%
<ListByResourceGroupAsync()-62.5%100%
<ListByResourceGroupAsync()-0%100%
ListByResourceGroup(...)-36.84%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
ListAsync(...)-100%100%
List(...)-100%100%
StartCreateOrUpdateAsync()-57.14%50%
StartCreateOrUpdate(...)-57.14%50%
StartUpdateAsync()-0%0%
StartUpdate(...)-0%0%
StartDeleteAsync()-58.33%50%
StartDelete(...)-58.33%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\GalleriesOperations.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 Galleries service client. </summary>
 19    public partial class GalleriesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 10823        internal GalleriesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of GalleriesOperations for mocking. </summary>
 39625        protected GalleriesOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of GalleriesOperations. </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 GalleriesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, 
 34        {
 39635            RestClient = new GalleriesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> Retrieves information about a Shared Image Gallery. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="galleryName"> The name of the Shared Image Gallery. </param>
 43        /// <param name="cancellationToken"> The cancellation token to use. </param>
 44        public virtual async Task<Response<Gallery>> GetAsync(string resourceGroupName, string galleryName, Cancellation
 45        {
 446            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.Get");
 447            scope.Start();
 48            try
 49            {
 450                return await RestClient.GetAsync(resourceGroupName, galleryName, cancellationToken).ConfigureAwait(false
 51            }
 052            catch (Exception e)
 53            {
 054                scope.Failed(e);
 055                throw;
 56            }
 457        }
 58
 59        /// <summary> Retrieves information about a Shared Image Gallery. </summary>
 60        /// <param name="resourceGroupName"> The name of the resource group. </param>
 61        /// <param name="galleryName"> The name of the Shared Image Gallery. </param>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public virtual Response<Gallery> Get(string resourceGroupName, string galleryName, CancellationToken cancellatio
 64        {
 465            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.Get");
 466            scope.Start();
 67            try
 68            {
 469                return RestClient.Get(resourceGroupName, galleryName, cancellationToken);
 70            }
 071            catch (Exception e)
 72            {
 073                scope.Failed(e);
 074                throw;
 75            }
 476        }
 77
 78        /// <summary> List galleries under a resource group. </summary>
 79        /// <param name="resourceGroupName"> The name of the resource group. </param>
 80        /// <param name="cancellationToken"> The cancellation token to use. </param>
 81        public virtual AsyncPageable<Gallery> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cance
 82        {
 483            if (resourceGroupName == null)
 84            {
 085                throw new ArgumentNullException(nameof(resourceGroupName));
 86            }
 87
 88            async Task<Page<Gallery>> FirstPageFunc(int? pageSizeHint)
 89            {
 490                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.ListByResourceGroup");
 491                scope.Start();
 92                try
 93                {
 494                    var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).Confi
 495                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 96                }
 097                catch (Exception e)
 98                {
 099                    scope.Failed(e);
 0100                    throw;
 101                }
 4102            }
 103            async Task<Page<Gallery>> NextPageFunc(string nextLink, int? pageSizeHint)
 104            {
 0105                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.ListByResourceGroup");
 0106                scope.Start();
 107                try
 108                {
 0109                    var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancel
 0110                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 111                }
 0112                catch (Exception e)
 113                {
 0114                    scope.Failed(e);
 0115                    throw;
 116                }
 0117            }
 4118            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 119        }
 120
 121        /// <summary> List galleries under a resource group. </summary>
 122        /// <param name="resourceGroupName"> The name of the resource group. </param>
 123        /// <param name="cancellationToken"> The cancellation token to use. </param>
 124        public virtual Pageable<Gallery> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationTok
 125        {
 4126            if (resourceGroupName == null)
 127            {
 0128                throw new ArgumentNullException(nameof(resourceGroupName));
 129            }
 130
 131            Page<Gallery> FirstPageFunc(int? pageSizeHint)
 132            {
 4133                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.ListByResourceGroup");
 4134                scope.Start();
 135                try
 136                {
 4137                    var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken);
 4138                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 139                }
 0140                catch (Exception e)
 141                {
 0142                    scope.Failed(e);
 0143                    throw;
 144                }
 4145            }
 146            Page<Gallery> NextPageFunc(string nextLink, int? pageSizeHint)
 147            {
 0148                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.ListByResourceGroup");
 0149                scope.Start();
 150                try
 151                {
 0152                    var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken
 0153                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 154                }
 0155                catch (Exception e)
 156                {
 0157                    scope.Failed(e);
 0158                    throw;
 159                }
 0160            }
 4161            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 162        }
 163
 164        /// <summary> List galleries under a subscription. </summary>
 165        /// <param name="cancellationToken"> The cancellation token to use. </param>
 166        public virtual AsyncPageable<Gallery> ListAsync(CancellationToken cancellationToken = default)
 167        {
 168            async Task<Page<Gallery>> FirstPageFunc(int? pageSizeHint)
 169            {
 2170                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.List");
 2171                scope.Start();
 172                try
 173                {
 2174                    var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false);
 2175                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 176                }
 0177                catch (Exception e)
 178                {
 0179                    scope.Failed(e);
 0180                    throw;
 181                }
 2182            }
 183            async Task<Page<Gallery>> NextPageFunc(string nextLink, int? pageSizeHint)
 184            {
 0185                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.List");
 0186                scope.Start();
 187                try
 188                {
 0189                    var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false)
 0190                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 191                }
 0192                catch (Exception e)
 193                {
 0194                    scope.Failed(e);
 0195                    throw;
 196                }
 0197            }
 2198            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 199        }
 200
 201        /// <summary> List galleries under a subscription. </summary>
 202        /// <param name="cancellationToken"> The cancellation token to use. </param>
 203        public virtual Pageable<Gallery> List(CancellationToken cancellationToken = default)
 204        {
 205            Page<Gallery> FirstPageFunc(int? pageSizeHint)
 206            {
 2207                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.List");
 2208                scope.Start();
 209                try
 210                {
 2211                    var response = RestClient.List(cancellationToken);
 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            }
 220            Page<Gallery> NextPageFunc(string nextLink, int? pageSizeHint)
 221            {
 0222                using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.List");
 0223                scope.Start();
 224                try
 225                {
 0226                    var response = RestClient.ListNextPage(nextLink, cancellationToken);
 0227                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 228                }
 0229                catch (Exception e)
 230                {
 0231                    scope.Failed(e);
 0232                    throw;
 233                }
 0234            }
 2235            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 236        }
 237
 238        /// <summary> Create or update a Shared Image Gallery. </summary>
 239        /// <param name="resourceGroupName"> The name of the resource group. </param>
 240        /// <param name="galleryName"> The name of the Shared Image Gallery. The allowed characters are alphabets and nu
 241        /// <param name="gallery"> Parameters supplied to the create or update Shared Image Gallery operation. </param>
 242        /// <param name="cancellationToken"> The cancellation token to use. </param>
 243        public virtual async Task<GalleriesCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupName, s
 244        {
 12245            if (resourceGroupName == null)
 246            {
 0247                throw new ArgumentNullException(nameof(resourceGroupName));
 248            }
 12249            if (galleryName == null)
 250            {
 0251                throw new ArgumentNullException(nameof(galleryName));
 252            }
 12253            if (gallery == null)
 254            {
 0255                throw new ArgumentNullException(nameof(gallery));
 256            }
 257
 12258            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.StartCreateOrUpdate");
 12259            scope.Start();
 260            try
 261            {
 12262                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, galleryName, gallery, can
 12263                return new GalleriesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpda
 264            }
 0265            catch (Exception e)
 266            {
 0267                scope.Failed(e);
 0268                throw;
 269            }
 12270        }
 271
 272        /// <summary> Create or update a Shared Image Gallery. </summary>
 273        /// <param name="resourceGroupName"> The name of the resource group. </param>
 274        /// <param name="galleryName"> The name of the Shared Image Gallery. The allowed characters are alphabets and nu
 275        /// <param name="gallery"> Parameters supplied to the create or update Shared Image Gallery operation. </param>
 276        /// <param name="cancellationToken"> The cancellation token to use. </param>
 277        public virtual GalleriesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string galleryName
 278        {
 12279            if (resourceGroupName == null)
 280            {
 0281                throw new ArgumentNullException(nameof(resourceGroupName));
 282            }
 12283            if (galleryName == null)
 284            {
 0285                throw new ArgumentNullException(nameof(galleryName));
 286            }
 12287            if (gallery == null)
 288            {
 0289                throw new ArgumentNullException(nameof(gallery));
 290            }
 291
 12292            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.StartCreateOrUpdate");
 12293            scope.Start();
 294            try
 295            {
 12296                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, galleryName, gallery, cancellationTo
 12297                return new GalleriesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpda
 298            }
 0299            catch (Exception e)
 300            {
 0301                scope.Failed(e);
 0302                throw;
 303            }
 12304        }
 305
 306        /// <summary> Update a Shared Image Gallery. </summary>
 307        /// <param name="resourceGroupName"> The name of the resource group. </param>
 308        /// <param name="galleryName"> The name of the Shared Image Gallery. The allowed characters are alphabets and nu
 309        /// <param name="gallery"> Parameters supplied to the update Shared Image Gallery operation. </param>
 310        /// <param name="cancellationToken"> The cancellation token to use. </param>
 311        public virtual async Task<GalleriesUpdateOperation> StartUpdateAsync(string resourceGroupName, string galleryNam
 312        {
 0313            if (resourceGroupName == null)
 314            {
 0315                throw new ArgumentNullException(nameof(resourceGroupName));
 316            }
 0317            if (galleryName == null)
 318            {
 0319                throw new ArgumentNullException(nameof(galleryName));
 320            }
 0321            if (gallery == null)
 322            {
 0323                throw new ArgumentNullException(nameof(gallery));
 324            }
 325
 0326            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.StartUpdate");
 0327            scope.Start();
 328            try
 329            {
 0330                var originalResponse = await RestClient.UpdateAsync(resourceGroupName, galleryName, gallery, cancellatio
 0331                return new GalleriesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resour
 332            }
 0333            catch (Exception e)
 334            {
 0335                scope.Failed(e);
 0336                throw;
 337            }
 0338        }
 339
 340        /// <summary> Update a Shared Image Gallery. </summary>
 341        /// <param name="resourceGroupName"> The name of the resource group. </param>
 342        /// <param name="galleryName"> The name of the Shared Image Gallery. The allowed characters are alphabets and nu
 343        /// <param name="gallery"> Parameters supplied to the update Shared Image Gallery operation. </param>
 344        /// <param name="cancellationToken"> The cancellation token to use. </param>
 345        public virtual GalleriesUpdateOperation StartUpdate(string resourceGroupName, string galleryName, GalleryUpdate 
 346        {
 0347            if (resourceGroupName == null)
 348            {
 0349                throw new ArgumentNullException(nameof(resourceGroupName));
 350            }
 0351            if (galleryName == null)
 352            {
 0353                throw new ArgumentNullException(nameof(galleryName));
 354            }
 0355            if (gallery == null)
 356            {
 0357                throw new ArgumentNullException(nameof(gallery));
 358            }
 359
 0360            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.StartUpdate");
 0361            scope.Start();
 362            try
 363            {
 0364                var originalResponse = RestClient.Update(resourceGroupName, galleryName, gallery, cancellationToken);
 0365                return new GalleriesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resour
 366            }
 0367            catch (Exception e)
 368            {
 0369                scope.Failed(e);
 0370                throw;
 371            }
 0372        }
 373
 374        /// <summary> Delete a Shared Image Gallery. </summary>
 375        /// <param name="resourceGroupName"> The name of the resource group. </param>
 376        /// <param name="galleryName"> The name of the Shared Image Gallery to be deleted. </param>
 377        /// <param name="cancellationToken"> The cancellation token to use. </param>
 378        public virtual async Task<GalleriesDeleteOperation> StartDeleteAsync(string resourceGroupName, string galleryNam
 379        {
 10380            if (resourceGroupName == null)
 381            {
 0382                throw new ArgumentNullException(nameof(resourceGroupName));
 383            }
 10384            if (galleryName == null)
 385            {
 0386                throw new ArgumentNullException(nameof(galleryName));
 387            }
 388
 10389            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.StartDelete");
 10390            scope.Start();
 391            try
 392            {
 10393                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, galleryName, cancellationToken).C
 10394                return new GalleriesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resour
 395            }
 0396            catch (Exception e)
 397            {
 0398                scope.Failed(e);
 0399                throw;
 400            }
 10401        }
 402
 403        /// <summary> Delete a Shared Image Gallery. </summary>
 404        /// <param name="resourceGroupName"> The name of the resource group. </param>
 405        /// <param name="galleryName"> The name of the Shared Image Gallery to be deleted. </param>
 406        /// <param name="cancellationToken"> The cancellation token to use. </param>
 407        public virtual GalleriesDeleteOperation StartDelete(string resourceGroupName, string galleryName, CancellationTo
 408        {
 10409            if (resourceGroupName == null)
 410            {
 0411                throw new ArgumentNullException(nameof(resourceGroupName));
 412            }
 10413            if (galleryName == null)
 414            {
 0415                throw new ArgumentNullException(nameof(galleryName));
 416            }
 417
 10418            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.StartDelete");
 10419            scope.Start();
 420            try
 421            {
 10422                var originalResponse = RestClient.Delete(resourceGroupName, galleryName, cancellationToken);
 10423                return new GalleriesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resour
 424            }
 0425            catch (Exception e)
 426            {
 0427                scope.Failed(e);
 0428                throw;
 429            }
 10430        }
 431    }
 432}