コード例 #1
0
        public virtual Pageable <ManagementGroupPolicyDefinitionResource> GetAll(string filter = null, int?top = null, CancellationToken cancellationToken = default)
        {
            Page <ManagementGroupPolicyDefinitionResource> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _managementGroupPolicyDefinitionPolicyDefinitionsClientDiagnostics.CreateScope("ManagementGroupPolicyDefinitionCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _managementGroupPolicyDefinitionPolicyDefinitionsRestClient.ListByManagementGroup(Id.Name, filter, top, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new ManagementGroupPolicyDefinitionResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <ManagementGroupPolicyDefinitionResource> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _managementGroupPolicyDefinitionPolicyDefinitionsClientDiagnostics.CreateScope("ManagementGroupPolicyDefinitionCollection.GetAll");
                scope.Start();
                try
                {
                    var response = _managementGroupPolicyDefinitionPolicyDefinitionsRestClient.ListByManagementGroupNextPage(nextLink, Id.Name, filter, top, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new ManagementGroupPolicyDefinitionResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }