/// <summary> /// Get the status of documents in the translation operation. /// </summary> /// <param name="options">Options to use when filtering result.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> used for the service call.</param> public virtual AsyncPageable <DocumentStatusResult> GetDocumentStatusesAsync(GetDocumentStatusesOptions options = default, CancellationToken cancellationToken = default) { async Task <Page <DocumentStatusResult> > FirstPageFunc(int?pageSizeHint) { using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(DocumentTranslationOperation)}.{nameof(GetDocumentStatuses)}"); scope.Start(); try { var idList = options?.Ids.Count > 0 ? options.Ids.Select(id => ClientCommon.ValidateModelId(id, "Id Filter")) : null; var statusList = options?.Statuses.Count > 0 ? options.Statuses.Select(status => status.ToString()) : null; var orderByList = options?.OrderBy.Count > 0 ? options.OrderBy.Select(order => order.ToGenerated()) : null; var response = await _serviceClient.GetDocumentsStatusAsync( new Guid(Id), ids : idList, statuses : statusList, createdDateTimeUtcStart : options?.CreatedAfter, createdDateTimeUtcEnd : options?.CreatedBefore, orderBy : orderByList, 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 <DocumentStatusResult> > NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(DocumentTranslationOperation)}.{nameof(GetDocumentStatuses)}"); scope.Start(); try { var response = await _serviceClient.GetDocumentsStatusNextPageAsync(nextLink, new Guid(Id), 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)); }