Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TA] Delete custom HealthStatusNextPageAsync for in health pagination #19183

Merged
merged 2 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ public class AnalyzeHealthcareEntitiesOperation : PageableOperation<AnalyzeHealt
/// </summary>
private readonly bool? _showStats;

/// <summary>
/// Provides the api version to use when doing pagination.
/// </summary>
private readonly string _apiVersion;

/// <summary>
/// Time when the operation will expire.
/// </summary>
Expand Down Expand Up @@ -144,15 +139,13 @@ public AnalyzeHealthcareEntitiesOperation(string operationId, TextAnalyticsClien
/// </summary>
/// <param name="serviceClient">The client for communicating with the Text Analytics Azure Cognitive Service through its REST API.</param>
/// <param name="diagnostics">The client diagnostics for exception creation in case of failure.</param>
/// <param name="apiversion">The specific api version to use.</param>
/// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param>
/// <param name="idToIndexMap"></param>
/// <param name="showStats"></param>
internal AnalyzeHealthcareEntitiesOperation(TextAnalyticsRestClient serviceClient, ClientDiagnostics diagnostics, string apiversion, string operationLocation, IDictionary<string, int> idToIndexMap, bool? showStats = default)
internal AnalyzeHealthcareEntitiesOperation(TextAnalyticsRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation, IDictionary<string, int> idToIndexMap, bool? showStats = default)
{
_serviceClient = serviceClient;
_diagnostics = diagnostics;
_apiVersion = apiversion;
_idToIndexMap = idToIndexMap;
_showStats = showStats;

Expand Down Expand Up @@ -333,7 +326,7 @@ async Task<Page<AnalyzeHealthcareEntitiesResultCollection>> NextPageFunc(string
//diagnostics scope?
try
{
Response<HealthcareJobState> jobState = await _serviceClient.HealthStatusNextPageAsync(_apiVersion, nextLink, _showStats).ConfigureAwait(false);
Response<HealthcareJobState> jobState = await _serviceClient.HealthStatusNextPageAsync(nextLink, _showStats).ConfigureAwait(false);

AnalyzeHealthcareEntitiesResultCollection result = Transforms.ConvertToAnalyzeHealthcareEntitiesResultCollection(jobState.Value.Results, _idToIndexMap);
return Page.FromValues(new List<AnalyzeHealthcareEntitiesResultCollection>() { result }, jobState.Value.NextLink, jobState.GetRawResponse());
Expand Down Expand Up @@ -362,7 +355,7 @@ Page<AnalyzeHealthcareEntitiesResultCollection> NextPageFunc(string nextLink, in
//diagnostics scope?
try
{
Response<HealthcareJobState> jobState = _serviceClient.HealthStatusNextPage(_apiVersion, nextLink, _showStats);
Response<HealthcareJobState> jobState = _serviceClient.HealthStatusNextPage(nextLink, _showStats);

AnalyzeHealthcareEntitiesResultCollection result = Transforms.ConvertToAnalyzeHealthcareEntitiesResultCollection(jobState.Value.Results, _idToIndexMap);
return Page.FromValues(new List<AnalyzeHealthcareEntitiesResultCollection>() { result }, jobState.Value.NextLink, jobState.GetRawResponse());
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ private AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities(MultiL

var _idToIndexMap = CreateIdToIndexMap(batchInput.Documents);

return new AnalyzeHealthcareEntitiesOperation(_serviceRestClient, _clientDiagnostics, _options.GetVersionString(), location, _idToIndexMap, options.IncludeStatistics);
return new AnalyzeHealthcareEntitiesOperation(_serviceRestClient, _clientDiagnostics, location, _idToIndexMap, options.IncludeStatistics);
}
catch (Exception e)
{
Expand All @@ -2233,7 +2233,7 @@ private async Task<AnalyzeHealthcareEntitiesOperation> StartAnalyzeHealthcareEnt

var _idToIndexMap = CreateIdToIndexMap(batchInput.Documents);

return new AnalyzeHealthcareEntitiesOperation(_serviceRestClient, _clientDiagnostics, _options.GetVersionString(), location, _idToIndexMap, options.IncludeStatistics);
return new AnalyzeHealthcareEntitiesOperation(_serviceRestClient, _clientDiagnostics, location, _idToIndexMap, options.IncludeStatistics);
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,81 +12,6 @@ namespace Azure.AI.TextAnalytics
{
internal partial class TextAnalyticsRestClient
{
private HttpMessage CreateHealthStatusNextPageRequest(string apiversion, string nextLink, bool? showStats)
{
var message = _pipeline.CreateMessage();
var request = message.Request;
request.Method = RequestMethod.Get;
var uri = new RawRequestUriBuilder();
uri.AppendRaw(endpoint, false);
uri.AppendRaw("/text/analytics/", false);
uri.AppendRaw(apiversion, false);
uri.AppendRawNextLink(nextLink, false);
if (showStats != null)
{
uri.AppendQuery("showStats", showStats.Value, true);
}
request.Uri = uri;
request.Headers.Add("Accept", "application/json, text/json");
return message;
}

/// <summary> Get details of the healthcare prediction job specified by the jobId. </summary>
/// <param name="apiversion"> The specific api version to use. </param>
/// <param name="nextLink"> The URL to the next page of results. </param>
/// <param name="showStats"> (Optional) if set to true, response will contain request and document level statistics. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public async Task<Response<HealthcareJobState>> HealthStatusNextPageAsync(string apiversion, string nextLink, bool? showStats = null, CancellationToken cancellationToken = default)
{
if (nextLink == null)
{
throw new ArgumentNullException(nameof(nextLink));
}

using var message = CreateHealthStatusNextPageRequest(apiversion, nextLink, showStats);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
switch (message.Response.Status)
{
case 200:
{
HealthcareJobState value = default;
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
value = HealthcareJobState.DeserializeHealthcareJobState(document.RootElement);
return Response.FromValue(value, message.Response);
}
default:
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
}
}

/// <summary> Get details of the healthcare prediction job specified by the jobId. </summary>
/// <param name="apiversion"> The specific api version to use. </param>
/// <param name="nextLink"> The URL to the next page of results. </param>
/// <param name="showStats"> (Optional) if set to true, response will contain request and document level statistics. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public Response<HealthcareJobState> HealthStatusNextPage(string apiversion, string nextLink, bool? showStats = null, CancellationToken cancellationToken = default)
{
if (nextLink == null)
{
throw new ArgumentNullException(nameof(nextLink));
}

using var message = CreateHealthStatusNextPageRequest(apiversion, nextLink, showStats);
_pipeline.Send(message, cancellationToken);
switch (message.Response.Status)
{
case 200:
{
HealthcareJobState value = default;
using var document = JsonDocument.Parse(message.Response.ContentStream);
value = HealthcareJobState.DeserializeHealthcareJobState(document.RootElement);
return Response.FromValue(value, message.Response);
}
default:
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
}
}

internal HttpMessage CreateAnalyzeStatusNextPageRequest(string apiversion, string nextLink, bool? showStats)
{
var message = _pipeline.CreateMessage();
Expand Down
Loading