< Summary

Class:Azure.ResourceManager.Resources.ResourceGroupsOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourceGroupsOperations.cs
Covered lines:78
Uncovered lines:64
Coverable lines:142
Total lines:372
Line coverage:54.9% (78 of 142)
Covered branches:4
Total branches:12
Branch coverage:33.3% (4 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
CheckExistenceAsync()-100%100%
CheckExistence(...)-100%100%
CreateOrUpdateAsync()-100%100%
CreateOrUpdate(...)-100%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
UpdateAsync()-57.14%100%
Update(...)-57.14%100%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
ListAsync(...)-100%100%
List(...)-100%100%
StartDeleteAsync()-70%100%
StartDelete(...)-70%100%
StartExportTemplateAsync()-0%0%
StartExportTemplate(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourceGroupsOperations.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.Resources.Models;
 15
 16namespace Azure.ResourceManager.Resources
 17{
 18    /// <summary> The ResourceGroups service client. </summary>
 19    public partial class ResourceGroupsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 21223        internal ResourceGroupsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of ResourceGroupsOperations for mocking. </summary>
 31225        protected ResourceGroupsOperations()
 26        {
 31227        }
 28        /// <summary> Initializes a new instance of ResourceGroupsOperations. </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"> The ID of the target subscription. </param>
 32        /// <param name="endpoint"> server parameter. </param>
 31233        internal ResourceGroupsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 34        {
 31235            RestClient = new ResourceGroupsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 31236            _clientDiagnostics = clientDiagnostics;
 31237            _pipeline = pipeline;
 31238        }
 39
 40        /// <summary> Checks whether a resource group exists. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa
 42        /// <param name="cancellationToken"> The cancellation token to use. </param>
 43        public virtual async Task<Response> CheckExistenceAsync(string resourceGroupName, CancellationToken cancellation
 44        {
 1045            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CheckExistence");
 1046            scope.Start();
 47            try
 48            {
 1049                return await RestClient.CheckExistenceAsync(resourceGroupName, cancellationToken).ConfigureAwait(false);
 50            }
 251            catch (Exception e)
 52            {
 253                scope.Failed(e);
 254                throw;
 55            }
 856        }
 57
 58        /// <summary> Checks whether a resource group exists. </summary>
 59        /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa
 60        /// <param name="cancellationToken"> The cancellation token to use. </param>
 61        public virtual Response CheckExistence(string resourceGroupName, CancellationToken cancellationToken = default)
 62        {
 1063            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CheckExistence");
 1064            scope.Start();
 65            try
 66            {
 1067                return RestClient.CheckExistence(resourceGroupName, cancellationToken);
 68            }
 269            catch (Exception e)
 70            {
 271                scope.Failed(e);
 272                throw;
 73            }
 874        }
 75
 76        /// <summary> Creates or updates a resource group. </summary>
 77        /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri
 78        /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param>
 79        /// <param name="cancellationToken"> The cancellation token to use. </param>
 80        public virtual async Task<Response<ResourceGroup>> CreateOrUpdateAsync(string resourceGroupName, ResourceGroup p
 81        {
 6082            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CreateOrUpdate");
 6083            scope.Start();
 84            try
 85            {
 6086                return await RestClient.CreateOrUpdateAsync(resourceGroupName, parameters, cancellationToken).ConfigureA
 87            }
 488            catch (Exception e)
 89            {
 490                scope.Failed(e);
 491                throw;
 92            }
 5693        }
 94
 95        /// <summary> Creates or updates a resource group. </summary>
 96        /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri
 97        /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public virtual Response<ResourceGroup> CreateOrUpdate(string resourceGroupName, ResourceGroup parameters, Cancel
 100        {
 60101            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CreateOrUpdate");
 60102            scope.Start();
 103            try
 104            {
 60105                return RestClient.CreateOrUpdate(resourceGroupName, parameters, cancellationToken);
 106            }
 4107            catch (Exception e)
 108            {
 4109                scope.Failed(e);
 4110                throw;
 111            }
 56112        }
 113
 114        /// <summary> Gets a resource group. </summary>
 115        /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para
 116        /// <param name="cancellationToken"> The cancellation token to use. </param>
 117        public virtual async Task<Response<ResourceGroup>> GetAsync(string resourceGroupName, CancellationToken cancella
 118        {
 8119            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Get");
 8120            scope.Start();
 121            try
 122            {
 8123                return await RestClient.GetAsync(resourceGroupName, cancellationToken).ConfigureAwait(false);
 124            }
 0125            catch (Exception e)
 126            {
 0127                scope.Failed(e);
 0128                throw;
 129            }
 8130        }
 131
 132        /// <summary> Gets a resource group. </summary>
 133        /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para
 134        /// <param name="cancellationToken"> The cancellation token to use. </param>
 135        public virtual Response<ResourceGroup> Get(string resourceGroupName, CancellationToken cancellationToken = defau
 136        {
 8137            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Get");
 8138            scope.Start();
 139            try
 140            {
 8141                return RestClient.Get(resourceGroupName, cancellationToken);
 142            }
 0143            catch (Exception e)
 144            {
 0145                scope.Failed(e);
 0146                throw;
 147            }
 8148        }
 149
 150        /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of 
 151        /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p
 152        /// <param name="parameters"> Parameters supplied to update a resource group. </param>
 153        /// <param name="cancellationToken"> The cancellation token to use. </param>
 154        public virtual async Task<Response<ResourceGroup>> UpdateAsync(string resourceGroupName, ResourceGroupPatchable 
 155        {
 2156            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Update");
 2157            scope.Start();
 158            try
 159            {
 2160                return await RestClient.UpdateAsync(resourceGroupName, parameters, cancellationToken).ConfigureAwait(fal
 161            }
 0162            catch (Exception e)
 163            {
 0164                scope.Failed(e);
 0165                throw;
 166            }
 2167        }
 168
 169        /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of 
 170        /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p
 171        /// <param name="parameters"> Parameters supplied to update a resource group. </param>
 172        /// <param name="cancellationToken"> The cancellation token to use. </param>
 173        public virtual Response<ResourceGroup> Update(string resourceGroupName, ResourceGroupPatchable parameters, Cance
 174        {
 2175            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Update");
 2176            scope.Start();
 177            try
 178            {
 2179                return RestClient.Update(resourceGroupName, parameters, cancellationToken);
 180            }
 0181            catch (Exception e)
 182            {
 0183                scope.Failed(e);
 0184                throw;
 185            }
 2186        }
 187
 188        /// <summary> Gets all the resource groups for a subscription. </summary>
 189        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;You can filter by tag names a
 190        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 191        /// <param name="cancellationToken"> The cancellation token to use. </param>
 192        public virtual AsyncPageable<ResourceGroup> ListAsync(string filter = null, int? top = null, CancellationToken c
 193        {
 194            async Task<Page<ResourceGroup>> FirstPageFunc(int? pageSizeHint)
 195            {
 10196                using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List");
 10197                scope.Start();
 198                try
 199                {
 10200                    var response = await RestClient.ListAsync(filter, top, cancellationToken).ConfigureAwait(false);
 10201                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 202                }
 0203                catch (Exception e)
 204                {
 0205                    scope.Failed(e);
 0206                    throw;
 207                }
 10208            }
 209            async Task<Page<ResourceGroup>> NextPageFunc(string nextLink, int? pageSizeHint)
 210            {
 0211                using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List");
 0212                scope.Start();
 213                try
 214                {
 0215                    var response = await RestClient.ListNextPageAsync(nextLink, filter, top, cancellationToken).Configur
 0216                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 217                }
 0218                catch (Exception e)
 219                {
 0220                    scope.Failed(e);
 0221                    throw;
 222                }
 0223            }
 10224            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 225        }
 226
 227        /// <summary> Gets all the resource groups for a subscription. </summary>
 228        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;You can filter by tag names a
 229        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 230        /// <param name="cancellationToken"> The cancellation token to use. </param>
 231        public virtual Pageable<ResourceGroup> List(string filter = null, int? top = null, CancellationToken cancellatio
 232        {
 233            Page<ResourceGroup> FirstPageFunc(int? pageSizeHint)
 234            {
 10235                using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List");
 10236                scope.Start();
 237                try
 238                {
 10239                    var response = RestClient.List(filter, top, cancellationToken);
 10240                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 241                }
 0242                catch (Exception e)
 243                {
 0244                    scope.Failed(e);
 0245                    throw;
 246                }
 10247            }
 248            Page<ResourceGroup> NextPageFunc(string nextLink, int? pageSizeHint)
 249            {
 0250                using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List");
 0251                scope.Start();
 252                try
 253                {
 0254                    var response = RestClient.ListNextPage(nextLink, filter, top, cancellationToken);
 0255                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 256                }
 0257                catch (Exception e)
 258                {
 0259                    scope.Failed(e);
 0260                    throw;
 261                }
 0262            }
 10263            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 264        }
 265
 266        /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group
 267        /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p
 268        /// <param name="cancellationToken"> The cancellation token to use. </param>
 269        public virtual async Task<ResourceGroupsDeleteOperation> StartDeleteAsync(string resourceGroupName, Cancellation
 270        {
 10271            if (resourceGroupName == null)
 272            {
 2273                throw new ArgumentNullException(nameof(resourceGroupName));
 274            }
 275
 8276            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartDelete");
 8277            scope.Start();
 278            try
 279            {
 8280                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, cancellationToken).ConfigureAwait
 8281                return new ResourceGroupsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r
 282            }
 0283            catch (Exception e)
 284            {
 0285                scope.Failed(e);
 0286                throw;
 287            }
 8288        }
 289
 290        /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group
 291        /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p
 292        /// <param name="cancellationToken"> The cancellation token to use. </param>
 293        public virtual ResourceGroupsDeleteOperation StartDelete(string resourceGroupName, CancellationToken cancellatio
 294        {
 10295            if (resourceGroupName == null)
 296            {
 2297                throw new ArgumentNullException(nameof(resourceGroupName));
 298            }
 299
 8300            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartDelete");
 8301            scope.Start();
 302            try
 303            {
 8304                var originalResponse = RestClient.Delete(resourceGroupName, cancellationToken);
 8305                return new ResourceGroupsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r
 306            }
 0307            catch (Exception e)
 308            {
 0309                scope.Failed(e);
 0310                throw;
 311            }
 8312        }
 313
 314        /// <summary> Captures the specified resource group as a template. </summary>
 315        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 316        /// <param name="parameters"> Parameters for exporting the template. </param>
 317        /// <param name="cancellationToken"> The cancellation token to use. </param>
 318        public virtual async Task<ResourceGroupsExportTemplateOperation> StartExportTemplateAsync(string resourceGroupNa
 319        {
 0320            if (resourceGroupName == null)
 321            {
 0322                throw new ArgumentNullException(nameof(resourceGroupName));
 323            }
 0324            if (parameters == null)
 325            {
 0326                throw new ArgumentNullException(nameof(parameters));
 327            }
 328
 0329            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartExportTemplate");
 0330            scope.Start();
 331            try
 332            {
 0333                var originalResponse = await RestClient.ExportTemplateAsync(resourceGroupName, parameters, cancellationT
 0334                return new ResourceGroupsExportTemplateOperation(_clientDiagnostics, _pipeline, RestClient.CreateExportT
 335            }
 0336            catch (Exception e)
 337            {
 0338                scope.Failed(e);
 0339                throw;
 340            }
 0341        }
 342
 343        /// <summary> Captures the specified resource group as a template. </summary>
 344        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 345        /// <param name="parameters"> Parameters for exporting the template. </param>
 346        /// <param name="cancellationToken"> The cancellation token to use. </param>
 347        public virtual ResourceGroupsExportTemplateOperation StartExportTemplate(string resourceGroupName, ExportTemplat
 348        {
 0349            if (resourceGroupName == null)
 350            {
 0351                throw new ArgumentNullException(nameof(resourceGroupName));
 352            }
 0353            if (parameters == null)
 354            {
 0355                throw new ArgumentNullException(nameof(parameters));
 356            }
 357
 0358            using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartExportTemplate");
 0359            scope.Start();
 360            try
 361            {
 0362                var originalResponse = RestClient.ExportTemplate(resourceGroupName, parameters, cancellationToken);
 0363                return new ResourceGroupsExportTemplateOperation(_clientDiagnostics, _pipeline, RestClient.CreateExportT
 364            }
 0365            catch (Exception e)
 366            {
 0367                scope.Failed(e);
 0368                throw;
 369            }
 0370        }
 371    }
 372}