@@ -507,6 +507,37 @@ public Observable<ServiceResponseWithHeaders<T, THeader>> call(ServiceResponse<T
507507 });
508508 }
509509
510+ /**
511+ * Handles an initial response from a POST or DELETE operation response by polling
512+ * the status of the operation asynchronously, calling the user provided callback
513+ * when the operation terminates.
514+ *
515+ * @param observable the initial observable from the POST or DELETE operation.
516+ * @param lroOptions long running operation options.
517+ * @param <T> the return type of the caller
518+ * @param <THeader> the type of the response header
519+ * @param resourceType the java.lang.reflect.Type of the resource.
520+ * @param headerType the type of the response header
521+ * @return the task describing the asynchronous polling.
522+ */
523+ public <T , THeader > Observable <ServiceResponseWithHeaders <T , THeader >> getPostOrDeleteResultWithHeadersAsync (Observable <Response <ResponseBody >> observable , final LongRunningOperationOptions lroOptions , Type resourceType , final Class <THeader > headerType ) {
524+ Observable <ServiceResponse <T >> bodyResponse = getPostOrDeleteResultAsync (observable , lroOptions , resourceType );
525+ return bodyResponse
526+ .flatMap (new Func1 <ServiceResponse <T >, Observable <ServiceResponseWithHeaders <T , THeader >>>() {
527+ @ Override
528+ public Observable <ServiceResponseWithHeaders <T , THeader >> call (ServiceResponse <T > serviceResponse ) {
529+ try {
530+ return Observable
531+ .just (new ServiceResponseWithHeaders <>(serviceResponse .body (),
532+ restClient ().serializerAdapter ().<THeader >deserialize (restClient ().serializerAdapter ().serialize (serviceResponse .response ().headers ()), headerType ),
533+ serviceResponse .response ()));
534+ } catch (IOException e ) {
535+ return Observable .error (e );
536+ }
537+ }
538+ });
539+ }
540+
510541 /**
511542 * Given a polling state representing state of a LRO operation, this method returns {@link Single} object,
512543 * when subscribed to it, a single poll will be performed and emits the latest polling state. A poll will be
0 commit comments