public virtual Pageable <SyncGroupLogProperties> GetLogs(string startTime, string endTime, SyncGroupLogType type, string continuationToken = null, CancellationToken cancellationToken = default) { if (startTime == null) { throw new ArgumentNullException(nameof(startTime)); } if (endTime == null) { throw new ArgumentNullException(nameof(endTime)); } Page <SyncGroupLogProperties> FirstPageFunc(int?pageSizeHint) { using var scope = _clientDiagnostics.CreateScope("SyncGroup.GetLogs"); scope.Start(); try { var response = _syncGroupsRestClient.ListLogs(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, startTime, endTime, type, continuationToken, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } Page <SyncGroupLogProperties> NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _clientDiagnostics.CreateScope("SyncGroup.GetLogs"); scope.Start(); try { var response = _syncGroupsRestClient.ListLogsNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, startTime, endTime, type, continuationToken, 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)); }
public virtual AsyncPageable <SyncGroupLogProperties> GetLogsAsync(string startTime, string endTime, SyncGroupLogType type, string continuationToken = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(startTime, nameof(startTime)); Argument.AssertNotNull(endTime, nameof(endTime)); async Task <Page <SyncGroupLogProperties> > FirstPageFunc(int?pageSizeHint) { using var scope = _syncGroupClientDiagnostics.CreateScope("SyncGroupResource.GetLogs"); scope.Start(); try { var response = await _syncGroupRestClient.ListLogsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, startTime, endTime, type, continuationToken, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } async Task <Page <SyncGroupLogProperties> > NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _syncGroupClientDiagnostics.CreateScope("SyncGroupResource.GetLogs"); scope.Start(); try { var response = await _syncGroupRestClient.ListLogsNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, startTime, endTime, type, continuationToken, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc)); }