Interface PollingStrategy<T,​U>

    • Method Detail

      • canPoll

        Mono<Boolean> canPoll​(Response<?> initialResponse)
        Checks if this strategy is able to handle polling for this long running operation based on the information in the initial response.
        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

        Mono<PollResponse<T>> onInitialResponse​(Response<?> response,
                                                PollingContext<T> pollingContext,
                                                TypeReference<T> pollResponseType)
        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.
        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
      • getResult

        Mono<U> getResult​(PollingContext<T> pollingContext,
                          TypeReference<U> resultType)
        Parses the response from the final GET call into the result type of the long running operation.
        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
      • cancel

        default Mono<T> cancel​(PollingContext<T> pollingContext,
                               PollResponse<T> initialResponse)
        Cancels the long running operation if service supports cancellation. If service does not support cancellation then the implementer should return Mono.error with an error message indicating absence of cancellation. Implementing this method is optional - by default, cancellation will not be supported unless overridden.
        Parameters:
        pollingContext - the PollingContext for the current polling operation, or null if the polling has started in a SyncPoller
        initialResponse - the response from the initial operation
        Returns:
        a publisher emitting the cancellation response content