예제 #1
0
        public virtual Pageable <TldLegalAgreement> GetAgreements(TopLevelDomainAgreementOption agreementOption, CancellationToken cancellationToken = default)
        {
            if (agreementOption == null)
            {
                throw new ArgumentNullException(nameof(agreementOption));
            }

            Page <TldLegalAgreement> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _topLevelDomainClientDiagnostics.CreateScope("TopLevelDomain.GetAgreements");
                scope.Start();
                try
                {
                    var response = _topLevelDomainRestClient.ListAgreements(Id.SubscriptionId, Id.Name, agreementOption, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <TldLegalAgreement> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _topLevelDomainClientDiagnostics.CreateScope("TopLevelDomain.GetAgreements");
                scope.Start();
                try
                {
                    var response = _topLevelDomainRestClient.ListAgreementsNextPage(nextLink, Id.SubscriptionId, Id.Name, agreementOption, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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