< Summary

Class:Azure.ResourceManager.Compute.ImagesOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\ImagesOperations.cs
Covered lines:76
Uncovered lines:98
Coverable lines:174
Total lines:434
Line coverage:43.6% (76 of 174)
Covered branches:18
Total branches:36
Branch coverage:50% (18 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()-0%100%
<ListAsync()-0%100%
ListAsync(...)-0%100%
List(...)-0%100%
StartCreateOrUpdateAsync()-57.14%50%
StartCreateOrUpdate(...)-57.14%50%
StartUpdateAsync()-57.14%50%
StartUpdate(...)-57.14%50%
StartDeleteAsync()-58.33%50%
StartDelete(...)-58.33%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\ImagesOperations.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 Images service client. </summary>
 19    public partial class ImagesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 5623        internal ImagesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of ImagesOperations for mocking. </summary>
 39625        protected ImagesOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of ImagesOperations. </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 ImagesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri
 34        {
 39635            RestClient = new ImagesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> Gets an image. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="imageName"> The name of the image. </param>
 43        /// <param name="expand"> The expand expression to apply on the operation. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<Image>> GetAsync(string resourceGroupName, string imageName, string expand = 
 46        {
 647            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.Get");
 648            scope.Start();
 49            try
 50            {
 651                return await RestClient.GetAsync(resourceGroupName, imageName, expand, cancellationToken).ConfigureAwait
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 658        }
 59
 60        /// <summary> Gets an image. </summary>
 61        /// <param name="resourceGroupName"> The name of the resource group. </param>
 62        /// <param name="imageName"> The name of the image. </param>
 63        /// <param name="expand"> The expand expression to apply on the operation. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<Image> Get(string resourceGroupName, string imageName, string expand = null, Cancellatio
 66        {
 667            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.Get");
 668            scope.Start();
 69            try
 70            {
 671                return RestClient.Get(resourceGroupName, imageName, expand, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 678        }
 79
 80        /// <summary> Gets the list of images under a resource group. </summary>
 81        /// <param name="resourceGroupName"> The name of the resource group. </param>
 82        /// <param name="cancellationToken"> The cancellation token to use. </param>
 83        public virtual AsyncPageable<Image> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cancell
 84        {
 285            if (resourceGroupName == null)
 86            {
 087                throw new ArgumentNullException(nameof(resourceGroupName));
 88            }
 89
 90            async Task<Page<Image>> FirstPageFunc(int? pageSizeHint)
 91            {
 292                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup");
 293                scope.Start();
 94                try
 95                {
 296                    var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).Confi
 297                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 98                }
 099                catch (Exception e)
 100                {
 0101                    scope.Failed(e);
 0102                    throw;
 103                }
 2104            }
 105            async Task<Page<Image>> NextPageFunc(string nextLink, int? pageSizeHint)
 106            {
 0107                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup");
 0108                scope.Start();
 109                try
 110                {
 0111                    var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancel
 0112                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 113                }
 0114                catch (Exception e)
 115                {
 0116                    scope.Failed(e);
 0117                    throw;
 118                }
 0119            }
 2120            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 121        }
 122
 123        /// <summary> Gets the list of images under a resource group. </summary>
 124        /// <param name="resourceGroupName"> The name of the resource group. </param>
 125        /// <param name="cancellationToken"> The cancellation token to use. </param>
 126        public virtual Pageable<Image> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken
 127        {
 2128            if (resourceGroupName == null)
 129            {
 0130                throw new ArgumentNullException(nameof(resourceGroupName));
 131            }
 132
 133            Page<Image> FirstPageFunc(int? pageSizeHint)
 134            {
 2135                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup");
 2136                scope.Start();
 137                try
 138                {
 2139                    var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken);
 2140                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 141                }
 0142                catch (Exception e)
 143                {
 0144                    scope.Failed(e);
 0145                    throw;
 146                }
 2147            }
 148            Page<Image> NextPageFunc(string nextLink, int? pageSizeHint)
 149            {
 0150                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.ListByResourceGroup");
 0151                scope.Start();
 152                try
 153                {
 0154                    var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken
 0155                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 156                }
 0157                catch (Exception e)
 158                {
 0159                    scope.Failed(e);
 0160                    throw;
 161                }
 0162            }
 2163            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 164        }
 165
 166        /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next
 167        /// <param name="cancellationToken"> The cancellation token to use. </param>
 168        public virtual AsyncPageable<Image> ListAsync(CancellationToken cancellationToken = default)
 169        {
 170            async Task<Page<Image>> FirstPageFunc(int? pageSizeHint)
 171            {
 0172                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List");
 0173                scope.Start();
 174                try
 175                {
 0176                    var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false);
 0177                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 178                }
 0179                catch (Exception e)
 180                {
 0181                    scope.Failed(e);
 0182                    throw;
 183                }
 0184            }
 185            async Task<Page<Image>> NextPageFunc(string nextLink, int? pageSizeHint)
 186            {
 0187                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List");
 0188                scope.Start();
 189                try
 190                {
 0191                    var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false)
 0192                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 193                }
 0194                catch (Exception e)
 195                {
 0196                    scope.Failed(e);
 0197                    throw;
 198                }
 0199            }
 0200            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 201        }
 202
 203        /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next
 204        /// <param name="cancellationToken"> The cancellation token to use. </param>
 205        public virtual Pageable<Image> List(CancellationToken cancellationToken = default)
 206        {
 207            Page<Image> FirstPageFunc(int? pageSizeHint)
 208            {
 0209                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List");
 0210                scope.Start();
 211                try
 212                {
 0213                    var response = RestClient.List(cancellationToken);
 0214                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 215                }
 0216                catch (Exception e)
 217                {
 0218                    scope.Failed(e);
 0219                    throw;
 220                }
 0221            }
 222            Page<Image> NextPageFunc(string nextLink, int? pageSizeHint)
 223            {
 0224                using var scope = _clientDiagnostics.CreateScope("ImagesOperations.List");
 0225                scope.Start();
 226                try
 227                {
 0228                    var response = RestClient.ListNextPage(nextLink, cancellationToken);
 0229                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 230                }
 0231                catch (Exception e)
 232                {
 0233                    scope.Failed(e);
 0234                    throw;
 235                }
 0236            }
 0237            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 238        }
 239
 240        /// <summary> Create or update an image. </summary>
 241        /// <param name="resourceGroupName"> The name of the resource group. </param>
 242        /// <param name="imageName"> The name of the image. </param>
 243        /// <param name="parameters"> Parameters supplied to the Create Image operation. </param>
 244        /// <param name="cancellationToken"> The cancellation token to use. </param>
 245        public virtual async Task<ImagesCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupName, stri
 246        {
 4247            if (resourceGroupName == null)
 248            {
 0249                throw new ArgumentNullException(nameof(resourceGroupName));
 250            }
 4251            if (imageName == null)
 252            {
 0253                throw new ArgumentNullException(nameof(imageName));
 254            }
 4255            if (parameters == null)
 256            {
 0257                throw new ArgumentNullException(nameof(parameters));
 258            }
 259
 4260            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartCreateOrUpdate");
 4261            scope.Start();
 262            try
 263            {
 4264                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, imageName, parameters, ca
 4265                return new ImagesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateR
 266            }
 0267            catch (Exception e)
 268            {
 0269                scope.Failed(e);
 0270                throw;
 271            }
 4272        }
 273
 274        /// <summary> Create or update an image. </summary>
 275        /// <param name="resourceGroupName"> The name of the resource group. </param>
 276        /// <param name="imageName"> The name of the image. </param>
 277        /// <param name="parameters"> Parameters supplied to the Create Image operation. </param>
 278        /// <param name="cancellationToken"> The cancellation token to use. </param>
 279        public virtual ImagesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string imageName, Ima
 280        {
 4281            if (resourceGroupName == null)
 282            {
 0283                throw new ArgumentNullException(nameof(resourceGroupName));
 284            }
 4285            if (imageName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(imageName));
 288            }
 4289            if (parameters == null)
 290            {
 0291                throw new ArgumentNullException(nameof(parameters));
 292            }
 293
 4294            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartCreateOrUpdate");
 4295            scope.Start();
 296            try
 297            {
 4298                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, imageName, parameters, cancellationT
 4299                return new ImagesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateR
 300            }
 0301            catch (Exception e)
 302            {
 0303                scope.Failed(e);
 0304                throw;
 305            }
 4306        }
 307
 308        /// <summary> Update an image. </summary>
 309        /// <param name="resourceGroupName"> The name of the resource group. </param>
 310        /// <param name="imageName"> The name of the image. </param>
 311        /// <param name="parameters"> Parameters supplied to the Update Image operation. </param>
 312        /// <param name="cancellationToken"> The cancellation token to use. </param>
 313        public virtual async Task<ImagesUpdateOperation> StartUpdateAsync(string resourceGroupName, string imageName, Im
 314        {
 2315            if (resourceGroupName == null)
 316            {
 0317                throw new ArgumentNullException(nameof(resourceGroupName));
 318            }
 2319            if (imageName == null)
 320            {
 0321                throw new ArgumentNullException(nameof(imageName));
 322            }
 2323            if (parameters == null)
 324            {
 0325                throw new ArgumentNullException(nameof(parameters));
 326            }
 327
 2328            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartUpdate");
 2329            scope.Start();
 330            try
 331            {
 2332                var originalResponse = await RestClient.UpdateAsync(resourceGroupName, imageName, parameters, cancellati
 2333                return new ImagesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resourceG
 334            }
 0335            catch (Exception e)
 336            {
 0337                scope.Failed(e);
 0338                throw;
 339            }
 2340        }
 341
 342        /// <summary> Update an image. </summary>
 343        /// <param name="resourceGroupName"> The name of the resource group. </param>
 344        /// <param name="imageName"> The name of the image. </param>
 345        /// <param name="parameters"> Parameters supplied to the Update Image operation. </param>
 346        /// <param name="cancellationToken"> The cancellation token to use. </param>
 347        public virtual ImagesUpdateOperation StartUpdate(string resourceGroupName, string imageName, ImageUpdate paramet
 348        {
 2349            if (resourceGroupName == null)
 350            {
 0351                throw new ArgumentNullException(nameof(resourceGroupName));
 352            }
 2353            if (imageName == null)
 354            {
 0355                throw new ArgumentNullException(nameof(imageName));
 356            }
 2357            if (parameters == null)
 358            {
 0359                throw new ArgumentNullException(nameof(parameters));
 360            }
 361
 2362            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartUpdate");
 2363            scope.Start();
 364            try
 365            {
 2366                var originalResponse = RestClient.Update(resourceGroupName, imageName, parameters, cancellationToken);
 2367                return new ImagesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resourceG
 368            }
 0369            catch (Exception e)
 370            {
 0371                scope.Failed(e);
 0372                throw;
 373            }
 2374        }
 375
 376        /// <summary> Deletes an Image. </summary>
 377        /// <param name="resourceGroupName"> The name of the resource group. </param>
 378        /// <param name="imageName"> The name of the image. </param>
 379        /// <param name="cancellationToken"> The cancellation token to use. </param>
 380        public virtual async Task<ImagesDeleteOperation> StartDeleteAsync(string resourceGroupName, string imageName, Ca
 381        {
 4382            if (resourceGroupName == null)
 383            {
 0384                throw new ArgumentNullException(nameof(resourceGroupName));
 385            }
 4386            if (imageName == null)
 387            {
 0388                throw new ArgumentNullException(nameof(imageName));
 389            }
 390
 4391            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartDelete");
 4392            scope.Start();
 393            try
 394            {
 4395                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, imageName, cancellationToken).Con
 4396                return new ImagesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceG
 397            }
 0398            catch (Exception e)
 399            {
 0400                scope.Failed(e);
 0401                throw;
 402            }
 4403        }
 404
 405        /// <summary> Deletes an Image. </summary>
 406        /// <param name="resourceGroupName"> The name of the resource group. </param>
 407        /// <param name="imageName"> The name of the image. </param>
 408        /// <param name="cancellationToken"> The cancellation token to use. </param>
 409        public virtual ImagesDeleteOperation StartDelete(string resourceGroupName, string imageName, CancellationToken c
 410        {
 4411            if (resourceGroupName == null)
 412            {
 0413                throw new ArgumentNullException(nameof(resourceGroupName));
 414            }
 4415            if (imageName == null)
 416            {
 0417                throw new ArgumentNullException(nameof(imageName));
 418            }
 419
 4420            using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartDelete");
 4421            scope.Start();
 422            try
 423            {
 4424                var originalResponse = RestClient.Delete(resourceGroupName, imageName, cancellationToken);
 4425                return new ImagesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resourceG
 426            }
 0427            catch (Exception e)
 428            {
 0429                scope.Failed(e);
 0430                throw;
 431            }
 4432        }
 433    }
 434}