< Summary

Class:Azure.ResourceManager.Resources.PolicyDefinitionsOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\PolicyDefinitionsOperations.cs
Covered lines:76
Uncovered lines:136
Coverable lines:212
Total lines:536
Line coverage:35.8% (76 of 212)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
CreateOrUpdateAsync()-100%100%
CreateOrUpdate(...)-100%100%
DeleteAsync()-57.14%100%
Delete(...)-57.14%100%
GetAsync()-100%100%
Get(...)-100%100%
GetBuiltInAsync()-57.14%100%
GetBuiltIn(...)-57.14%100%
CreateOrUpdateAtManagementGroupAsync()-0%100%
CreateOrUpdateAtManagementGroup(...)-0%100%
DeleteAtManagementGroupAsync()-0%100%
DeleteAtManagementGroup(...)-0%100%
GetAtManagementGroupAsync()-0%100%
GetAtManagementGroup(...)-0%100%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
ListAsync(...)-100%100%
List(...)-100%100%
<ListBuiltInAsync()-62.5%100%
<ListBuiltInAsync()-0%100%
ListBuiltInAsync(...)-100%100%
ListBuiltIn(...)-100%100%
ListByManagementGroupAsync(...)-0%0%
<ListByManagementGroupAsync()-0%100%
<ListByManagementGroupAsync()-0%100%
ListByManagementGroup(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\PolicyDefinitionsOperations.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 PolicyDefinitions service client. </summary>
 19    public partial class PolicyDefinitionsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 1363223        internal PolicyDefinitionsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of PolicyDefinitionsOperations for mocking. </summary>
 25625        protected PolicyDefinitionsOperations()
 26        {
 25627        }
 28        /// <summary> Initializes a new instance of PolicyDefinitionsOperations. </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>
 25633        internal PolicyDefinitionsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip
 34        {
 25635            RestClient = new PolicyDefinitionsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 25636            _clientDiagnostics = clientDiagnostics;
 25637            _pipeline = pipeline;
 25638        }
 39
 40        /// <summary> This operation creates or updates a policy definition in the given subscription with the given nam
 41        /// <param name="policyDefinitionName"> The name of the policy definition to create. </param>
 42        /// <param name="parameters"> The policy definition properties. </param>
 43        /// <param name="cancellationToken"> The cancellation token to use. </param>
 44        public virtual async Task<Response<PolicyDefinition>> CreateOrUpdateAsync(string policyDefinitionName, PolicyDef
 45        {
 3446            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdate");
 3447            scope.Start();
 48            try
 49            {
 3450                return await RestClient.CreateOrUpdateAsync(policyDefinitionName, parameters, cancellationToken).Configu
 51            }
 852            catch (Exception e)
 53            {
 854                scope.Failed(e);
 855                throw;
 56            }
 2657        }
 58
 59        /// <summary> This operation creates or updates a policy definition in the given subscription with the given nam
 60        /// <param name="policyDefinitionName"> The name of the policy definition to create. </param>
 61        /// <param name="parameters"> The policy definition properties. </param>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public virtual Response<PolicyDefinition> CreateOrUpdate(string policyDefinitionName, PolicyDefinition parameter
 64        {
 3465            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdate");
 3466            scope.Start();
 67            try
 68            {
 3469                return RestClient.CreateOrUpdate(policyDefinitionName, parameters, cancellationToken);
 70            }
 871            catch (Exception e)
 72            {
 873                scope.Failed(e);
 874                throw;
 75            }
 2676        }
 77
 78        /// <summary> This operation deletes the policy definition in the given subscription with the given name. </summ
 79        /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param>
 80        /// <param name="cancellationToken"> The cancellation token to use. </param>
 81        public virtual async Task<Response> DeleteAsync(string policyDefinitionName, CancellationToken cancellationToken
 82        {
 12283            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Delete");
 12284            scope.Start();
 85            try
 86            {
 12287                return await RestClient.DeleteAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false);
 88            }
 089            catch (Exception e)
 90            {
 091                scope.Failed(e);
 092                throw;
 93            }
 12294        }
 95
 96        /// <summary> This operation deletes the policy definition in the given subscription with the given name. </summ
 97        /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public virtual Response Delete(string policyDefinitionName, CancellationToken cancellationToken = default)
 100        {
 122101            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Delete");
 122102            scope.Start();
 103            try
 104            {
 122105                return RestClient.Delete(policyDefinitionName, cancellationToken);
 106            }
 0107            catch (Exception e)
 108            {
 0109                scope.Failed(e);
 0110                throw;
 111            }
 122112        }
 113
 114        /// <summary> This operation retrieves the policy definition in the given subscription with the given name. </su
 115        /// <param name="policyDefinitionName"> The name of the policy definition to get. </param>
 116        /// <param name="cancellationToken"> The cancellation token to use. </param>
 117        public virtual async Task<Response<PolicyDefinition>> GetAsync(string policyDefinitionName, CancellationToken ca
 118        {
 28119            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Get");
 28120            scope.Start();
 121            try
 122            {
 28123                return await RestClient.GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false);
 124            }
 18125            catch (Exception e)
 126            {
 18127                scope.Failed(e);
 18128                throw;
 129            }
 10130        }
 131
 132        /// <summary> This operation retrieves the policy definition in the given subscription with the given name. </su
 133        /// <param name="policyDefinitionName"> The name of the policy definition to get. </param>
 134        /// <param name="cancellationToken"> The cancellation token to use. </param>
 135        public virtual Response<PolicyDefinition> Get(string policyDefinitionName, CancellationToken cancellationToken =
 136        {
 28137            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Get");
 28138            scope.Start();
 139            try
 140            {
 28141                return RestClient.Get(policyDefinitionName, cancellationToken);
 142            }
 18143            catch (Exception e)
 144            {
 18145                scope.Failed(e);
 18146                throw;
 147            }
 10148        }
 149
 150        /// <summary> This operation retrieves the built-in policy definition with the given name. </summary>
 151        /// <param name="policyDefinitionName"> The name of the built-in policy definition to get. </param>
 152        /// <param name="cancellationToken"> The cancellation token to use. </param>
 153        public virtual async Task<Response<PolicyDefinition>> GetBuiltInAsync(string policyDefinitionName, CancellationT
 154        {
 6604155            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetBuiltIn");
 6604156            scope.Start();
 157            try
 158            {
 6604159                return await RestClient.GetBuiltInAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false);
 160            }
 0161            catch (Exception e)
 162            {
 0163                scope.Failed(e);
 0164                throw;
 165            }
 6604166        }
 167
 168        /// <summary> This operation retrieves the built-in policy definition with the given name. </summary>
 169        /// <param name="policyDefinitionName"> The name of the built-in policy definition to get. </param>
 170        /// <param name="cancellationToken"> The cancellation token to use. </param>
 171        public virtual Response<PolicyDefinition> GetBuiltIn(string policyDefinitionName, CancellationToken cancellation
 172        {
 6604173            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetBuiltIn");
 6604174            scope.Start();
 175            try
 176            {
 6604177                return RestClient.GetBuiltIn(policyDefinitionName, cancellationToken);
 178            }
 0179            catch (Exception e)
 180            {
 0181                scope.Failed(e);
 0182                throw;
 183            }
 6604184        }
 185
 186        /// <summary> This operation creates or updates a policy definition in the given management group with the given
 187        /// <param name="policyDefinitionName"> The name of the policy definition to create. </param>
 188        /// <param name="managementGroupId"> The ID of the management group. </param>
 189        /// <param name="parameters"> The policy definition properties. </param>
 190        /// <param name="cancellationToken"> The cancellation token to use. </param>
 191        public virtual async Task<Response<PolicyDefinition>> CreateOrUpdateAtManagementGroupAsync(string policyDefiniti
 192        {
 0193            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdateAtManagementGrou
 0194            scope.Start();
 195            try
 196            {
 0197                return await RestClient.CreateOrUpdateAtManagementGroupAsync(policyDefinitionName, managementGroupId, pa
 198            }
 0199            catch (Exception e)
 200            {
 0201                scope.Failed(e);
 0202                throw;
 203            }
 0204        }
 205
 206        /// <summary> This operation creates or updates a policy definition in the given management group with the given
 207        /// <param name="policyDefinitionName"> The name of the policy definition to create. </param>
 208        /// <param name="managementGroupId"> The ID of the management group. </param>
 209        /// <param name="parameters"> The policy definition properties. </param>
 210        /// <param name="cancellationToken"> The cancellation token to use. </param>
 211        public virtual Response<PolicyDefinition> CreateOrUpdateAtManagementGroup(string policyDefinitionName, string ma
 212        {
 0213            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdateAtManagementGrou
 0214            scope.Start();
 215            try
 216            {
 0217                return RestClient.CreateOrUpdateAtManagementGroup(policyDefinitionName, managementGroupId, parameters, c
 218            }
 0219            catch (Exception e)
 220            {
 0221                scope.Failed(e);
 0222                throw;
 223            }
 0224        }
 225
 226        /// <summary> This operation deletes the policy definition in the given management group with the given name. </
 227        /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param>
 228        /// <param name="managementGroupId"> The ID of the management group. </param>
 229        /// <param name="cancellationToken"> The cancellation token to use. </param>
 230        public virtual async Task<Response> DeleteAtManagementGroupAsync(string policyDefinitionName, string managementG
 231        {
 0232            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.DeleteAtManagementGroup");
 0233            scope.Start();
 234            try
 235            {
 0236                return await RestClient.DeleteAtManagementGroupAsync(policyDefinitionName, managementGroupId, cancellati
 237            }
 0238            catch (Exception e)
 239            {
 0240                scope.Failed(e);
 0241                throw;
 242            }
 0243        }
 244
 245        /// <summary> This operation deletes the policy definition in the given management group with the given name. </
 246        /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param>
 247        /// <param name="managementGroupId"> The ID of the management group. </param>
 248        /// <param name="cancellationToken"> The cancellation token to use. </param>
 249        public virtual Response DeleteAtManagementGroup(string policyDefinitionName, string managementGroupId, Cancellat
 250        {
 0251            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.DeleteAtManagementGroup");
 0252            scope.Start();
 253            try
 254            {
 0255                return RestClient.DeleteAtManagementGroup(policyDefinitionName, managementGroupId, cancellationToken);
 256            }
 0257            catch (Exception e)
 258            {
 0259                scope.Failed(e);
 0260                throw;
 261            }
 0262        }
 263
 264        /// <summary> This operation retrieves the policy definition in the given management group with the given name. 
 265        /// <param name="policyDefinitionName"> The name of the policy definition to get. </param>
 266        /// <param name="managementGroupId"> The ID of the management group. </param>
 267        /// <param name="cancellationToken"> The cancellation token to use. </param>
 268        public virtual async Task<Response<PolicyDefinition>> GetAtManagementGroupAsync(string policyDefinitionName, str
 269        {
 0270            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetAtManagementGroup");
 0271            scope.Start();
 272            try
 273            {
 0274                return await RestClient.GetAtManagementGroupAsync(policyDefinitionName, managementGroupId, cancellationT
 275            }
 0276            catch (Exception e)
 277            {
 0278                scope.Failed(e);
 0279                throw;
 280            }
 0281        }
 282
 283        /// <summary> This operation retrieves the policy definition in the given management group with the given name. 
 284        /// <param name="policyDefinitionName"> The name of the policy definition to get. </param>
 285        /// <param name="managementGroupId"> The ID of the management group. </param>
 286        /// <param name="cancellationToken"> The cancellation token to use. </param>
 287        public virtual Response<PolicyDefinition> GetAtManagementGroup(string policyDefinitionName, string managementGro
 288        {
 0289            using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetAtManagementGroup");
 0290            scope.Start();
 291            try
 292            {
 0293                return RestClient.GetAtManagementGroup(policyDefinitionName, managementGroupId, cancellationToken);
 294            }
 0295            catch (Exception e)
 296            {
 0297                scope.Failed(e);
 0298                throw;
 299            }
 0300        }
 301
 302        /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary>
 303        /// <param name="cancellationToken"> The cancellation token to use. </param>
 304        public virtual AsyncPageable<PolicyDefinition> ListAsync(CancellationToken cancellationToken = default)
 305        {
 306            async Task<Page<PolicyDefinition>> FirstPageFunc(int? pageSizeHint)
 307            {
 22308                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List");
 22309                scope.Start();
 310                try
 311                {
 22312                    var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false);
 22313                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 314                }
 0315                catch (Exception e)
 316                {
 0317                    scope.Failed(e);
 0318                    throw;
 319                }
 22320            }
 321            async Task<Page<PolicyDefinition>> NextPageFunc(string nextLink, int? pageSizeHint)
 322            {
 0323                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List");
 0324                scope.Start();
 325                try
 326                {
 0327                    var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false)
 0328                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 329                }
 0330                catch (Exception e)
 331                {
 0332                    scope.Failed(e);
 0333                    throw;
 334                }
 0335            }
 22336            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 337        }
 338
 339        /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary>
 340        /// <param name="cancellationToken"> The cancellation token to use. </param>
 341        public virtual Pageable<PolicyDefinition> List(CancellationToken cancellationToken = default)
 342        {
 343            Page<PolicyDefinition> FirstPageFunc(int? pageSizeHint)
 344            {
 22345                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List");
 22346                scope.Start();
 347                try
 348                {
 22349                    var response = RestClient.List(cancellationToken);
 22350                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 351                }
 0352                catch (Exception e)
 353                {
 0354                    scope.Failed(e);
 0355                    throw;
 356                }
 22357            }
 358            Page<PolicyDefinition> NextPageFunc(string nextLink, int? pageSizeHint)
 359            {
 0360                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List");
 0361                scope.Start();
 362                try
 363                {
 0364                    var response = RestClient.ListNextPage(nextLink, cancellationToken);
 0365                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 366                }
 0367                catch (Exception e)
 368                {
 0369                    scope.Failed(e);
 0370                    throw;
 371                }
 0372            }
 22373            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 374        }
 375
 376        /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary>
 377        /// <param name="cancellationToken"> The cancellation token to use. </param>
 378        public virtual AsyncPageable<PolicyDefinition> ListBuiltInAsync(CancellationToken cancellationToken = default)
 379        {
 380            async Task<Page<PolicyDefinition>> FirstPageFunc(int? pageSizeHint)
 381            {
 6382                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn");
 6383                scope.Start();
 384                try
 385                {
 6386                    var response = await RestClient.ListBuiltInAsync(cancellationToken).ConfigureAwait(false);
 6387                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 388                }
 0389                catch (Exception e)
 390                {
 0391                    scope.Failed(e);
 0392                    throw;
 393                }
 6394            }
 395            async Task<Page<PolicyDefinition>> NextPageFunc(string nextLink, int? pageSizeHint)
 396            {
 0397                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn");
 0398                scope.Start();
 399                try
 400                {
 0401                    var response = await RestClient.ListBuiltInNextPageAsync(nextLink, cancellationToken).ConfigureAwait
 0402                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 403                }
 0404                catch (Exception e)
 405                {
 0406                    scope.Failed(e);
 0407                    throw;
 408                }
 0409            }
 6410            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 411        }
 412
 413        /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary>
 414        /// <param name="cancellationToken"> The cancellation token to use. </param>
 415        public virtual Pageable<PolicyDefinition> ListBuiltIn(CancellationToken cancellationToken = default)
 416        {
 417            Page<PolicyDefinition> FirstPageFunc(int? pageSizeHint)
 418            {
 6419                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn");
 6420                scope.Start();
 421                try
 422                {
 6423                    var response = RestClient.ListBuiltIn(cancellationToken);
 6424                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 425                }
 0426                catch (Exception e)
 427                {
 0428                    scope.Failed(e);
 0429                    throw;
 430                }
 6431            }
 432            Page<PolicyDefinition> NextPageFunc(string nextLink, int? pageSizeHint)
 433            {
 0434                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn");
 0435                scope.Start();
 436                try
 437                {
 0438                    var response = RestClient.ListBuiltInNextPage(nextLink, cancellationToken);
 0439                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 440                }
 0441                catch (Exception e)
 442                {
 0443                    scope.Failed(e);
 0444                    throw;
 445                }
 0446            }
 6447            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 448        }
 449
 450        /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa
 451        /// <param name="managementGroupId"> The ID of the management group. </param>
 452        /// <param name="cancellationToken"> The cancellation token to use. </param>
 453        public virtual AsyncPageable<PolicyDefinition> ListByManagementGroupAsync(string managementGroupId, Cancellation
 454        {
 0455            if (managementGroupId == null)
 456            {
 0457                throw new ArgumentNullException(nameof(managementGroupId));
 458            }
 459
 460            async Task<Page<PolicyDefinition>> FirstPageFunc(int? pageSizeHint)
 461            {
 0462                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup");
 0463                scope.Start();
 464                try
 465                {
 0466                    var response = await RestClient.ListByManagementGroupAsync(managementGroupId, cancellationToken).Con
 0467                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 468                }
 0469                catch (Exception e)
 470                {
 0471                    scope.Failed(e);
 0472                    throw;
 473                }
 0474            }
 475            async Task<Page<PolicyDefinition>> NextPageFunc(string nextLink, int? pageSizeHint)
 476            {
 0477                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup");
 0478                scope.Start();
 479                try
 480                {
 0481                    var response = await RestClient.ListByManagementGroupNextPageAsync(nextLink, managementGroupId, canc
 0482                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 483                }
 0484                catch (Exception e)
 485                {
 0486                    scope.Failed(e);
 0487                    throw;
 488                }
 0489            }
 0490            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 491        }
 492
 493        /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa
 494        /// <param name="managementGroupId"> The ID of the management group. </param>
 495        /// <param name="cancellationToken"> The cancellation token to use. </param>
 496        public virtual Pageable<PolicyDefinition> ListByManagementGroup(string managementGroupId, CancellationToken canc
 497        {
 0498            if (managementGroupId == null)
 499            {
 0500                throw new ArgumentNullException(nameof(managementGroupId));
 501            }
 502
 503            Page<PolicyDefinition> FirstPageFunc(int? pageSizeHint)
 504            {
 0505                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup");
 0506                scope.Start();
 507                try
 508                {
 0509                    var response = RestClient.ListByManagementGroup(managementGroupId, cancellationToken);
 0510                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 511                }
 0512                catch (Exception e)
 513                {
 0514                    scope.Failed(e);
 0515                    throw;
 516                }
 0517            }
 518            Page<PolicyDefinition> NextPageFunc(string nextLink, int? pageSizeHint)
 519            {
 0520                using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup");
 0521                scope.Start();
 522                try
 523                {
 0524                    var response = RestClient.ListByManagementGroupNextPage(nextLink, managementGroupId, cancellationTok
 0525                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 526                }
 0527                catch (Exception e)
 528                {
 0529                    scope.Failed(e);
 0530                    throw;
 531                }
 0532            }
 0533            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 534        }
 535    }
 536}