< Summary

Class:Azure.ResourceManager.Resources.PolicyAssignmentsOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\PolicyAssignmentsOperations.cs
Covered lines:100
Uncovered lines:160
Coverable lines:260
Total lines:654
Line coverage:38.4% (100 of 260)
Covered branches:12
Total branches:32
Branch coverage:37.5% (12 of 32)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
DeleteAsync()-57.14%100%
Delete(...)-57.14%100%
CreateAsync()-100%100%
Create(...)-100%100%
GetAsync()-100%100%
Get(...)-100%100%
DeleteByIdAsync()-0%100%
DeleteById(...)-0%100%
CreateByIdAsync()-0%100%
CreateById(...)-0%100%
GetByIdAsync()-57.14%100%
GetById(...)-57.14%100%
ListForResourceGroupAsync(...)-36.84%50%
<ListForResourceGroupAsync()-62.5%100%
<ListForResourceGroupAsync()-0%100%
ListForResourceGroup(...)-36.84%50%
ListForResourceAsync(...)-40.74%50%
<ListForResourceAsync()-62.5%100%
<ListForResourceAsync()-0%100%
ListForResource(...)-40.74%50%
ListForManagementGroupAsync(...)-0%0%
<ListForManagementGroupAsync()-0%100%
<ListForManagementGroupAsync()-0%100%
ListForManagementGroup(...)-0%0%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
ListAsync(...)-100%100%
List(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\PolicyAssignmentsOperations.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 PolicyAssignments service client. </summary>
 19    public partial class PolicyAssignmentsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 9623        internal PolicyAssignmentsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of PolicyAssignmentsOperations for mocking. </summary>
 25625        protected PolicyAssignmentsOperations()
 26        {
 25627        }
 28        /// <summary> Initializes a new instance of PolicyAssignmentsOperations. </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 PolicyAssignmentsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip
 34        {
 25635            RestClient = new PolicyAssignmentsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 25636            _clientDiagnostics = clientDiagnostics;
 25637            _pipeline = pipeline;
 25638        }
 39
 40        /// <summary> This operation deletes a policy assignment, given its name and the scope it was created in. The sc
 41        /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: &apos;/
 42        /// <param name="policyAssignmentName"> The name of the policy assignment to delete. </param>
 43        /// <param name="cancellationToken"> The cancellation token to use. </param>
 44        public virtual async Task<Response<PolicyAssignment>> DeleteAsync(string scope, string policyAssignmentName, Can
 45        {
 846            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.Delete");
 847            scope0.Start();
 48            try
 49            {
 850                return await RestClient.DeleteAsync(scope, policyAssignmentName, cancellationToken).ConfigureAwait(false
 51            }
 052            catch (Exception e)
 53            {
 054                scope0.Failed(e);
 055                throw;
 56            }
 857        }
 58
 59        /// <summary> This operation deletes a policy assignment, given its name and the scope it was created in. The sc
 60        /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: &apos;/
 61        /// <param name="policyAssignmentName"> The name of the policy assignment to delete. </param>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public virtual Response<PolicyAssignment> Delete(string scope, string policyAssignmentName, CancellationToken ca
 64        {
 865            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.Delete");
 866            scope0.Start();
 67            try
 68            {
 869                return RestClient.Delete(scope, policyAssignmentName, cancellationToken);
 70            }
 071            catch (Exception e)
 72            {
 073                scope0.Failed(e);
 074                throw;
 75            }
 876        }
 77
 78        /// <summary>  This operation creates or updates a policy assignment with the given scope and name. Policy assig
 79        /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: &apos;/
 80        /// <param name="policyAssignmentName"> The name of the policy assignment. </param>
 81        /// <param name="parameters"> Parameters for the policy assignment. </param>
 82        /// <param name="cancellationToken"> The cancellation token to use. </param>
 83        public virtual async Task<Response<PolicyAssignment>> CreateAsync(string scope, string policyAssignmentName, Pol
 84        {
 1685            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.Create");
 1686            scope0.Start();
 87            try
 88            {
 1689                return await RestClient.CreateAsync(scope, policyAssignmentName, parameters, cancellationToken).Configur
 90            }
 691            catch (Exception e)
 92            {
 693                scope0.Failed(e);
 694                throw;
 95            }
 1096        }
 97
 98        /// <summary>  This operation creates or updates a policy assignment with the given scope and name. Policy assig
 99        /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: &apos;/
 100        /// <param name="policyAssignmentName"> The name of the policy assignment. </param>
 101        /// <param name="parameters"> Parameters for the policy assignment. </param>
 102        /// <param name="cancellationToken"> The cancellation token to use. </param>
 103        public virtual Response<PolicyAssignment> Create(string scope, string policyAssignmentName, PolicyAssignment par
 104        {
 16105            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.Create");
 16106            scope0.Start();
 107            try
 108            {
 16109                return RestClient.Create(scope, policyAssignmentName, parameters, cancellationToken);
 110            }
 6111            catch (Exception e)
 112            {
 6113                scope0.Failed(e);
 6114                throw;
 115            }
 10116        }
 117
 118        /// <summary> This operation retrieves a single policy assignment, given its name and the scope it was created a
 119        /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: &apos;/
 120        /// <param name="policyAssignmentName"> The name of the policy assignment to get. </param>
 121        /// <param name="cancellationToken"> The cancellation token to use. </param>
 122        public virtual async Task<Response<PolicyAssignment>> GetAsync(string scope, string policyAssignmentName, Cancel
 123        {
 10124            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.Get");
 10125            scope0.Start();
 126            try
 127            {
 10128                return await RestClient.GetAsync(scope, policyAssignmentName, cancellationToken).ConfigureAwait(false);
 129            }
 4130            catch (Exception e)
 131            {
 4132                scope0.Failed(e);
 4133                throw;
 134            }
 6135        }
 136
 137        /// <summary> This operation retrieves a single policy assignment, given its name and the scope it was created a
 138        /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: &apos;/
 139        /// <param name="policyAssignmentName"> The name of the policy assignment to get. </param>
 140        /// <param name="cancellationToken"> The cancellation token to use. </param>
 141        public virtual Response<PolicyAssignment> Get(string scope, string policyAssignmentName, CancellationToken cance
 142        {
 10143            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.Get");
 10144            scope0.Start();
 145            try
 146            {
 10147                return RestClient.Get(scope, policyAssignmentName, cancellationToken);
 148            }
 4149            catch (Exception e)
 150            {
 4151                scope0.Failed(e);
 4152                throw;
 153            }
 6154        }
 155
 156        /// <summary> This operation deletes the policy with the given ID. Policy assignment IDs have this format: &apos
 157        /// <param name="policyAssignmentId"> The ID of the policy assignment to delete. Use the format &apos;{scope}/pr
 158        /// <param name="cancellationToken"> The cancellation token to use. </param>
 159        public virtual async Task<Response<PolicyAssignment>> DeleteByIdAsync(string policyAssignmentId, CancellationTok
 160        {
 0161            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.DeleteById");
 0162            scope0.Start();
 163            try
 164            {
 0165                return await RestClient.DeleteByIdAsync(policyAssignmentId, cancellationToken).ConfigureAwait(false);
 166            }
 0167            catch (Exception e)
 168            {
 0169                scope0.Failed(e);
 0170                throw;
 171            }
 0172        }
 173
 174        /// <summary> This operation deletes the policy with the given ID. Policy assignment IDs have this format: &apos
 175        /// <param name="policyAssignmentId"> The ID of the policy assignment to delete. Use the format &apos;{scope}/pr
 176        /// <param name="cancellationToken"> The cancellation token to use. </param>
 177        public virtual Response<PolicyAssignment> DeleteById(string policyAssignmentId, CancellationToken cancellationTo
 178        {
 0179            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.DeleteById");
 0180            scope0.Start();
 181            try
 182            {
 0183                return RestClient.DeleteById(policyAssignmentId, cancellationToken);
 184            }
 0185            catch (Exception e)
 186            {
 0187                scope0.Failed(e);
 0188                throw;
 189            }
 0190        }
 191
 192        /// <summary> This operation creates or updates the policy assignment with the given ID. Policy assignments made
 193        /// <param name="policyAssignmentId"> The ID of the policy assignment to create. Use the format &apos;{scope}/pr
 194        /// <param name="parameters"> Parameters for policy assignment. </param>
 195        /// <param name="cancellationToken"> The cancellation token to use. </param>
 196        public virtual async Task<Response<PolicyAssignment>> CreateByIdAsync(string policyAssignmentId, PolicyAssignmen
 197        {
 0198            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.CreateById");
 0199            scope0.Start();
 200            try
 201            {
 0202                return await RestClient.CreateByIdAsync(policyAssignmentId, parameters, cancellationToken).ConfigureAwai
 203            }
 0204            catch (Exception e)
 205            {
 0206                scope0.Failed(e);
 0207                throw;
 208            }
 0209        }
 210
 211        /// <summary> This operation creates or updates the policy assignment with the given ID. Policy assignments made
 212        /// <param name="policyAssignmentId"> The ID of the policy assignment to create. Use the format &apos;{scope}/pr
 213        /// <param name="parameters"> Parameters for policy assignment. </param>
 214        /// <param name="cancellationToken"> The cancellation token to use. </param>
 215        public virtual Response<PolicyAssignment> CreateById(string policyAssignmentId, PolicyAssignment parameters, Can
 216        {
 0217            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.CreateById");
 0218            scope0.Start();
 219            try
 220            {
 0221                return RestClient.CreateById(policyAssignmentId, parameters, cancellationToken);
 222            }
 0223            catch (Exception e)
 224            {
 0225                scope0.Failed(e);
 0226                throw;
 227            }
 0228        }
 229
 230        /// <summary> The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this f
 231        /// <param name="policyAssignmentId"> The ID of the policy assignment to get. Use the format &apos;{scope}/provi
 232        /// <param name="cancellationToken"> The cancellation token to use. </param>
 233        public virtual async Task<Response<PolicyAssignment>> GetByIdAsync(string policyAssignmentId, CancellationToken 
 234        {
 4235            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.GetById");
 4236            scope0.Start();
 237            try
 238            {
 4239                return await RestClient.GetByIdAsync(policyAssignmentId, cancellationToken).ConfigureAwait(false);
 240            }
 0241            catch (Exception e)
 242            {
 0243                scope0.Failed(e);
 0244                throw;
 245            }
 4246        }
 247
 248        /// <summary> The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this f
 249        /// <param name="policyAssignmentId"> The ID of the policy assignment to get. Use the format &apos;{scope}/provi
 250        /// <param name="cancellationToken"> The cancellation token to use. </param>
 251        public virtual Response<PolicyAssignment> GetById(string policyAssignmentId, CancellationToken cancellationToken
 252        {
 4253            using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.GetById");
 4254            scope0.Start();
 255            try
 256            {
 4257                return RestClient.GetById(policyAssignmentId, cancellationToken);
 258            }
 0259            catch (Exception e)
 260            {
 0261                scope0.Failed(e);
 0262                throw;
 263            }
 4264        }
 265
 266        /// <summary> This operation retrieves the list of all policy assignments associated with the given resource gro
 267        /// <param name="resourceGroupName"> The name of the resource group that contains policy assignments. </param>
 268        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 269        /// <param name="cancellationToken"> The cancellation token to use. </param>
 270        public virtual AsyncPageable<PolicyAssignment> ListForResourceGroupAsync(string resourceGroupName, string filter
 271        {
 2272            if (resourceGroupName == null)
 273            {
 0274                throw new ArgumentNullException(nameof(resourceGroupName));
 275            }
 276
 277            async Task<Page<PolicyAssignment>> FirstPageFunc(int? pageSizeHint)
 278            {
 2279                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResourceGroup");
 2280                scope0.Start();
 281                try
 282                {
 2283                    var response = await RestClient.ListForResourceGroupAsync(resourceGroupName, filter, cancellationTok
 2284                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 285                }
 0286                catch (Exception e)
 287                {
 0288                    scope0.Failed(e);
 0289                    throw;
 290                }
 2291            }
 292            async Task<Page<PolicyAssignment>> NextPageFunc(string nextLink, int? pageSizeHint)
 293            {
 0294                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResourceGroup");
 0295                scope0.Start();
 296                try
 297                {
 0298                    var response = await RestClient.ListForResourceGroupNextPageAsync(nextLink, resourceGroupName, filte
 0299                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 300                }
 0301                catch (Exception e)
 302                {
 0303                    scope0.Failed(e);
 0304                    throw;
 305                }
 0306            }
 2307            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 308        }
 309
 310        /// <summary> This operation retrieves the list of all policy assignments associated with the given resource gro
 311        /// <param name="resourceGroupName"> The name of the resource group that contains policy assignments. </param>
 312        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 313        /// <param name="cancellationToken"> The cancellation token to use. </param>
 314        public virtual Pageable<PolicyAssignment> ListForResourceGroup(string resourceGroupName, string filter = null, C
 315        {
 2316            if (resourceGroupName == null)
 317            {
 0318                throw new ArgumentNullException(nameof(resourceGroupName));
 319            }
 320
 321            Page<PolicyAssignment> FirstPageFunc(int? pageSizeHint)
 322            {
 2323                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResourceGroup");
 2324                scope0.Start();
 325                try
 326                {
 2327                    var response = RestClient.ListForResourceGroup(resourceGroupName, filter, cancellationToken);
 2328                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 329                }
 0330                catch (Exception e)
 331                {
 0332                    scope0.Failed(e);
 0333                    throw;
 334                }
 2335            }
 336            Page<PolicyAssignment> NextPageFunc(string nextLink, int? pageSizeHint)
 337            {
 0338                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResourceGroup");
 0339                scope0.Start();
 340                try
 341                {
 0342                    var response = RestClient.ListForResourceGroupNextPage(nextLink, resourceGroupName, filter, cancella
 0343                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 344                }
 0345                catch (Exception e)
 346                {
 0347                    scope0.Failed(e);
 0348                    throw;
 349                }
 0350            }
 2351            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 352        }
 353
 354        /// <summary> This operation retrieves the list of all policy assignments associated with the specified resource
 355        /// <param name="resourceGroupName"> The name of the resource group containing the resource. </param>
 356        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. For example, the namespace 
 357        /// <param name="parentResourcePath"> The parent resource path. Use empty string if there is none. </param>
 358        /// <param name="resourceType"> The resource type name. For example the type name of a web app is &apos;sites&ap
 359        /// <param name="resourceName"> The name of the resource. </param>
 360        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 361        /// <param name="cancellationToken"> The cancellation token to use. </param>
 362        public virtual AsyncPageable<PolicyAssignment> ListForResourceAsync(string resourceGroupName, string resourcePro
 363        {
 2364            if (resourceGroupName == null)
 365            {
 0366                throw new ArgumentNullException(nameof(resourceGroupName));
 367            }
 2368            if (resourceProviderNamespace == null)
 369            {
 0370                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 371            }
 2372            if (parentResourcePath == null)
 373            {
 0374                throw new ArgumentNullException(nameof(parentResourcePath));
 375            }
 2376            if (resourceType == null)
 377            {
 0378                throw new ArgumentNullException(nameof(resourceType));
 379            }
 2380            if (resourceName == null)
 381            {
 0382                throw new ArgumentNullException(nameof(resourceName));
 383            }
 384
 385            async Task<Page<PolicyAssignment>> FirstPageFunc(int? pageSizeHint)
 386            {
 2387                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResource");
 2388                scope0.Start();
 389                try
 390                {
 2391                    var response = await RestClient.ListForResourceAsync(resourceGroupName, resourceProviderNamespace, p
 2392                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 393                }
 0394                catch (Exception e)
 395                {
 0396                    scope0.Failed(e);
 0397                    throw;
 398                }
 2399            }
 400            async Task<Page<PolicyAssignment>> NextPageFunc(string nextLink, int? pageSizeHint)
 401            {
 0402                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResource");
 0403                scope0.Start();
 404                try
 405                {
 0406                    var response = await RestClient.ListForResourceNextPageAsync(nextLink, resourceGroupName, resourcePr
 0407                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 408                }
 0409                catch (Exception e)
 410                {
 0411                    scope0.Failed(e);
 0412                    throw;
 413                }
 0414            }
 2415            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 416        }
 417
 418        /// <summary> This operation retrieves the list of all policy assignments associated with the specified resource
 419        /// <param name="resourceGroupName"> The name of the resource group containing the resource. </param>
 420        /// <param name="resourceProviderNamespace"> The namespace of the resource provider. For example, the namespace 
 421        /// <param name="parentResourcePath"> The parent resource path. Use empty string if there is none. </param>
 422        /// <param name="resourceType"> The resource type name. For example the type name of a web app is &apos;sites&ap
 423        /// <param name="resourceName"> The name of the resource. </param>
 424        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 425        /// <param name="cancellationToken"> The cancellation token to use. </param>
 426        public virtual Pageable<PolicyAssignment> ListForResource(string resourceGroupName, string resourceProviderNames
 427        {
 2428            if (resourceGroupName == null)
 429            {
 0430                throw new ArgumentNullException(nameof(resourceGroupName));
 431            }
 2432            if (resourceProviderNamespace == null)
 433            {
 0434                throw new ArgumentNullException(nameof(resourceProviderNamespace));
 435            }
 2436            if (parentResourcePath == null)
 437            {
 0438                throw new ArgumentNullException(nameof(parentResourcePath));
 439            }
 2440            if (resourceType == null)
 441            {
 0442                throw new ArgumentNullException(nameof(resourceType));
 443            }
 2444            if (resourceName == null)
 445            {
 0446                throw new ArgumentNullException(nameof(resourceName));
 447            }
 448
 449            Page<PolicyAssignment> FirstPageFunc(int? pageSizeHint)
 450            {
 2451                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResource");
 2452                scope0.Start();
 453                try
 454                {
 2455                    var response = RestClient.ListForResource(resourceGroupName, resourceProviderNamespace, parentResour
 2456                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 457                }
 0458                catch (Exception e)
 459                {
 0460                    scope0.Failed(e);
 0461                    throw;
 462                }
 2463            }
 464            Page<PolicyAssignment> NextPageFunc(string nextLink, int? pageSizeHint)
 465            {
 0466                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForResource");
 0467                scope0.Start();
 468                try
 469                {
 0470                    var response = RestClient.ListForResourceNextPage(nextLink, resourceGroupName, resourceProviderNames
 0471                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 472                }
 0473                catch (Exception e)
 474                {
 0475                    scope0.Failed(e);
 0476                    throw;
 477                }
 0478            }
 2479            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 480        }
 481
 482        /// <summary> This operation retrieves the list of all policy assignments applicable to the management group tha
 483        /// <param name="managementGroupId"> The ID of the management group. </param>
 484        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 485        /// <param name="cancellationToken"> The cancellation token to use. </param>
 486        public virtual AsyncPageable<PolicyAssignment> ListForManagementGroupAsync(string managementGroupId, string filt
 487        {
 0488            if (managementGroupId == null)
 489            {
 0490                throw new ArgumentNullException(nameof(managementGroupId));
 491            }
 0492            if (filter == null)
 493            {
 0494                throw new ArgumentNullException(nameof(filter));
 495            }
 496
 497            async Task<Page<PolicyAssignment>> FirstPageFunc(int? pageSizeHint)
 498            {
 0499                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForManagementGroup");
 0500                scope0.Start();
 501                try
 502                {
 0503                    var response = await RestClient.ListForManagementGroupAsync(managementGroupId, filter, cancellationT
 0504                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 505                }
 0506                catch (Exception e)
 507                {
 0508                    scope0.Failed(e);
 0509                    throw;
 510                }
 0511            }
 512            async Task<Page<PolicyAssignment>> NextPageFunc(string nextLink, int? pageSizeHint)
 513            {
 0514                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForManagementGroup");
 0515                scope0.Start();
 516                try
 517                {
 0518                    var response = await RestClient.ListForManagementGroupNextPageAsync(nextLink, managementGroupId, fil
 0519                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 520                }
 0521                catch (Exception e)
 522                {
 0523                    scope0.Failed(e);
 0524                    throw;
 525                }
 0526            }
 0527            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 528        }
 529
 530        /// <summary> This operation retrieves the list of all policy assignments applicable to the management group tha
 531        /// <param name="managementGroupId"> The ID of the management group. </param>
 532        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 533        /// <param name="cancellationToken"> The cancellation token to use. </param>
 534        public virtual Pageable<PolicyAssignment> ListForManagementGroup(string managementGroupId, string filter, Cancel
 535        {
 0536            if (managementGroupId == null)
 537            {
 0538                throw new ArgumentNullException(nameof(managementGroupId));
 539            }
 0540            if (filter == null)
 541            {
 0542                throw new ArgumentNullException(nameof(filter));
 543            }
 544
 545            Page<PolicyAssignment> FirstPageFunc(int? pageSizeHint)
 546            {
 0547                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForManagementGroup");
 0548                scope0.Start();
 549                try
 550                {
 0551                    var response = RestClient.ListForManagementGroup(managementGroupId, filter, cancellationToken);
 0552                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 553                }
 0554                catch (Exception e)
 555                {
 0556                    scope0.Failed(e);
 0557                    throw;
 558                }
 0559            }
 560            Page<PolicyAssignment> NextPageFunc(string nextLink, int? pageSizeHint)
 561            {
 0562                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.ListForManagementGroup");
 0563                scope0.Start();
 564                try
 565                {
 0566                    var response = RestClient.ListForManagementGroupNextPage(nextLink, managementGroupId, filter, cancel
 0567                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 568                }
 0569                catch (Exception e)
 570                {
 0571                    scope0.Failed(e);
 0572                    throw;
 573                }
 0574            }
 0575            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 576        }
 577
 578        /// <summary> This operation retrieves the list of all policy assignments associated with the given subscription
 579        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 580        /// <param name="cancellationToken"> The cancellation token to use. </param>
 581        public virtual AsyncPageable<PolicyAssignment> ListAsync(string filter = null, CancellationToken cancellationTok
 582        {
 583            async Task<Page<PolicyAssignment>> FirstPageFunc(int? pageSizeHint)
 584            {
 6585                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.List");
 6586                scope0.Start();
 587                try
 588                {
 6589                    var response = await RestClient.ListAsync(filter, cancellationToken).ConfigureAwait(false);
 6590                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 591                }
 0592                catch (Exception e)
 593                {
 0594                    scope0.Failed(e);
 0595                    throw;
 596                }
 6597            }
 598            async Task<Page<PolicyAssignment>> NextPageFunc(string nextLink, int? pageSizeHint)
 599            {
 0600                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.List");
 0601                scope0.Start();
 602                try
 603                {
 0604                    var response = await RestClient.ListNextPageAsync(nextLink, filter, cancellationToken).ConfigureAwai
 0605                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 606                }
 0607                catch (Exception e)
 608                {
 0609                    scope0.Failed(e);
 0610                    throw;
 611                }
 0612            }
 6613            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 614        }
 615
 616        /// <summary> This operation retrieves the list of all policy assignments associated with the given subscription
 617        /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: &apos;atScope()&ap
 618        /// <param name="cancellationToken"> The cancellation token to use. </param>
 619        public virtual Pageable<PolicyAssignment> List(string filter = null, CancellationToken cancellationToken = defau
 620        {
 621            Page<PolicyAssignment> FirstPageFunc(int? pageSizeHint)
 622            {
 6623                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.List");
 6624                scope0.Start();
 625                try
 626                {
 6627                    var response = RestClient.List(filter, cancellationToken);
 6628                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 629                }
 0630                catch (Exception e)
 631                {
 0632                    scope0.Failed(e);
 0633                    throw;
 634                }
 6635            }
 636            Page<PolicyAssignment> NextPageFunc(string nextLink, int? pageSizeHint)
 637            {
 0638                using var scope0 = _clientDiagnostics.CreateScope("PolicyAssignmentsOperations.List");
 0639                scope0.Start();
 640                try
 641                {
 0642                    var response = RestClient.ListNextPage(nextLink, filter, cancellationToken);
 0643                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 644                }
 0645                catch (Exception e)
 646                {
 0647                    scope0.Failed(e);
 0648                    throw;
 649                }
 0650            }
 6651            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 652        }
 653    }
 654}