/// <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 Pageable <DocumentStatusResult> GetDocumentStatuses(GetDocumentStatusesOptions options = default, CancellationToken cancellationToken = default) { 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 = _serviceClient.GetDocumentsStatus( new Guid(Id), ids: idList, statuses: statusList, createdDateTimeUtcStart: options?.CreatedAfter, createdDateTimeUtcEnd: options?.CreatedBefore, orderBy: orderByList, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } Page <DocumentStatusResult> NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(DocumentTranslationOperation)}.{nameof(GetDocumentStatuses)}"); scope.Start(); try { var response = _serviceClient.GetDocumentsStatusNextPage(nextLink, new Guid(Id), 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)); }
/// <summary> /// Get the status of all documents in the translation operation. /// </summary> /// <param name="cancellationToken">A <see cref="CancellationToken"/> used for the service call.</param> public virtual Pageable <DocumentStatus> GetAllDocumentStatuses(CancellationToken cancellationToken = default) { Page <DocumentStatus> FirstPageFunc(int?pageSizeHint) { using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(DocumentTranslationOperation)}.{nameof(GetAllDocumentStatuses)}"); scope.Start(); try { var response = _serviceClient.GetDocumentsStatus(new Guid(Id), cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } Page <DocumentStatus> NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(DocumentTranslationOperation)}.{nameof(GetAllDocumentStatuses)}"); scope.Start(); try { var response = _serviceClient.GetDocumentsStatusNextPage(nextLink, new Guid(Id), 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)); }