Class OperationResourcePollingStrategy<T,U>

java.lang.Object
com.azure.core.util.polling.OperationResourcePollingStrategy<T,U>
Type Parameters:
T - the type of the response type from a polling call, or BinaryData if raw response body should be kept
U - the type of the final result object to deserialize into, or BinaryData if raw response body should be kept
All Implemented Interfaces:
PollingStrategy<T,U>

public class OperationResourcePollingStrategy<T,U> extends Object implements PollingStrategy<T,U>
Implements a operation resource polling strategy, typically from Operation-Location.
  • Constructor Details

    • OperationResourcePollingStrategy

      public OperationResourcePollingStrategy(HttpPipeline httpPipeline)
      Creates an instance of the operation resource polling strategy using a JSON serializer and "Operation-Location" as the header for polling.
      Parameters:
      httpPipeline - an instance of HttpPipeline to send requests with
    • OperationResourcePollingStrategy

      public OperationResourcePollingStrategy(HttpPipeline httpPipeline, ObjectSerializer serializer, String operationLocationHeaderName)
      Creates an instance of the operation resource polling strategy.
      Parameters:
      httpPipeline - an instance of HttpPipeline to send requests with
      serializer - a custom serializer for serializing and deserializing polling responses
      operationLocationHeaderName - a custom header for polling the long running operation
    • OperationResourcePollingStrategy

      public OperationResourcePollingStrategy(HttpPipeline httpPipeline, ObjectSerializer serializer, String operationLocationHeaderName, Context context)
      Creates an instance of the operation resource polling strategy.
      Parameters:
      httpPipeline - an instance of HttpPipeline to send requests with
      serializer - a custom serializer for serializing and deserializing polling responses
      operationLocationHeaderName - a custom header for polling the long running operation
      context - an instance of Context
  • Method Details

    • canPoll

      public Mono<Boolean> canPoll(Response<?> initialResponse)
      Description copied from interface: PollingStrategy
      Checks if this strategy is able to handle polling for this long-running operation based on the information in the initial response.
      Specified by:
      canPoll in interface PollingStrategy<T,U>
      Parameters:
      initialResponse - the response from the initial method call to activate the long-running operation
      Returns:
      true if this polling strategy can handle the initial response, false if not
    • onInitialResponse

      public Mono<PollResponse<T>> onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
      Description copied from interface: PollingStrategy
      Parses the initial response into a LongRunningOperationStatus, and stores information useful for polling in the PollingContext. If the result is anything other than LongRunningOperationStatus.IN_PROGRESS, the long-running operation will be terminated and none of the other methods will be invoked.
      Specified by:
      onInitialResponse in interface PollingStrategy<T,U>
      Parameters:
      response - the response from the initial method call to activate the long-running operation
      pollingContext - the PollingContext for the current polling operation
      pollResponseType - the TypeReference of the response type from a polling call, or BinaryData if raw response body should be kept. This should match the generic parameter PollingStrategy.
      Returns:
      a publisher emitting the poll response containing the status and the response content
    • poll

      public Mono<PollResponse<T>> poll(PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
      Description copied from interface: PollingStrategy
      Parses the response from the polling URL into a PollResponse, and stores information useful for further polling and final response in the PollingContext. The result must have the LongRunningOperationStatus specified, and the entire polling response content as a BinaryData.
      Specified by:
      poll in interface PollingStrategy<T,U>
      Parameters:
      pollingContext - the PollingContext for the current polling operation
      pollResponseType - the TypeReference of the response type from a polling call, or BinaryData if raw response body should be kept. This should match the generic parameter PollingStrategy.
      Returns:
      a publisher emitting the poll response containing the status and the response content
    • getResult

      public Mono<U> getResult(PollingContext<T> pollingContext, TypeReference<U> resultType)
      Description copied from interface: PollingStrategy
      Parses the response from the final GET call into the result type of the long-running operation.
      Specified by:
      getResult in interface PollingStrategy<T,U>
      Parameters:
      pollingContext - the PollingContext for the current polling operation
      resultType - the TypeReference of the final result object to deserialize into, or BinaryData if raw response body should be kept.
      Returns:
      a publisher emitting the final result