diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java index 2995b04a87018..3d3d9f0399cd6 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceCall.java @@ -12,6 +12,7 @@ import java.util.List; +import com.microsoft.rest.ServiceResponseWithHeaders; import rx.Observable; import rx.Subscriber; import rx.functions.Func1; @@ -45,6 +46,26 @@ public static ServiceCall> create(Observable return serviceCall; } + public static ServiceCall> createWithHeaders(Observable, V>> first, final Func1, V>>> next, final ListOperationCallback callback) { + final AzureServiceCall> serviceCall = new AzureServiceCall<>(); + final PagingSubscriber subscriber = new PagingSubscriber<>(serviceCall, new Func1>>>() { + @Override + public Observable>> call(String s) { + return next.call(s) + .map(new Func1, V>, ServiceResponse>>() { + @Override + public ServiceResponse> call(ServiceResponseWithHeaders, V> pageVServiceResponseWithHeaders) { + return pageVServiceResponseWithHeaders; + } + }); + } + }, callback); + serviceCall.setSubscription(first + .single() + .subscribe(subscriber)); + return serviceCall; + } + /** * The subscriber that handles user callback and automatically subscribes to the next page. *