1919import com .ibm .cloud .sdk .core .http .ResponseConverter ;
2020import com .ibm .cloud .sdk .core .http .ServiceCall ;
2121import com .ibm .cloud .sdk .core .http .ServiceCallback ;
22- import com .ibm .cloud .sdk .core .http .ServiceCallbackWithDetails ;
2322import com .ibm .cloud .sdk .core .service .exception .BadRequestException ;
2423import com .ibm .cloud .sdk .core .service .exception .ConflictException ;
2524import com .ibm .cloud .sdk .core .service .exception .ForbiddenException ;
3534import com .ibm .cloud .sdk .core .service .security .IamTokenManager ;
3635import com .ibm .cloud .sdk .core .util .CredentialUtils ;
3736import com .ibm .cloud .sdk .core .util .RequestUtils ;
38- import jersey . repackaged . jsr166e . CompletableFuture ;
37+ import io . reactivex . Single ;
3938import okhttp3 .Call ;
4039import okhttp3 .Callback ;
4140import okhttp3 .Credentials ;
4746
4847import java .io .IOException ;
4948import java .util .Map ;
49+ import java .util .concurrent .Callable ;
5050import java .util .logging .Logger ;
5151import java .util .regex .Pattern ;
5252
@@ -479,47 +479,18 @@ public ServiceCall<T> addHeader(String name, String value) {
479479 }
480480
481481 @ Override
482- public T execute () {
482+ public com . ibm . cloud . sdk . core . http . Response < T > execute () {
483483 try {
484484 Response response = call .execute ();
485- return processServiceCall (converter , response );
486- } catch (IOException e ) {
487- throw new RuntimeException (e );
488- }
489- }
490-
491- @ Override
492- public com .ibm .cloud .sdk .core .http .Response <T > executeWithDetails () throws RuntimeException {
493- try {
494- Response httpResponse = call .execute ();
495- T responseModel = processServiceCall (converter , httpResponse );
496- return new com .ibm .cloud .sdk .core .http .Response <>(responseModel , httpResponse );
485+ T responseModel = processServiceCall (converter , response );
486+ return new com .ibm .cloud .sdk .core .http .Response <>(responseModel , response );
497487 } catch (IOException e ) {
498488 throw new RuntimeException (e );
499489 }
500490 }
501491
502492 @ Override
503493 public void enqueue (final ServiceCallback <? super T > callback ) {
504- call .enqueue (new Callback () {
505- @ Override
506- public void onFailure (Call call , IOException e ) {
507- callback .onFailure (e );
508- }
509-
510- @ Override
511- public void onResponse (Call call , Response response ) {
512- try {
513- callback .onResponse (processServiceCall (converter , response ));
514- } catch (Exception e ) {
515- callback .onFailure (e );
516- }
517- }
518- });
519- }
520-
521- @ Override
522- public void enqueueWithDetails (final ServiceCallbackWithDetails <T > callback ) {
523494 call .enqueue (new Callback () {
524495 @ Override
525496 public void onFailure (Call call , IOException e ) {
@@ -539,51 +510,15 @@ public void onResponse(Call call, Response response) {
539510 }
540511
541512 @ Override
542- public CompletableFuture <T > rx () {
543- final CompletableFuture <T > completableFuture = new CompletableFuture <T >();
544-
545- call .enqueue (new Callback () {
513+ public Single <com .ibm .cloud .sdk .core .http .Response <T >> reactiveRequest () {
514+ return Single .fromCallable (new Callable <com .ibm .cloud .sdk .core .http .Response <T >>() {
546515 @ Override
547- public void onFailure (Call call , IOException e ) {
548- completableFuture .completeExceptionally (e );
549- }
550-
551- @ Override
552- public void onResponse (Call call , Response response ) {
553- try {
554- completableFuture .complete (processServiceCall (converter , response ));
555- } catch (Exception e ) {
556- completableFuture .completeExceptionally (e );
557- }
558- }
559- });
560-
561- return completableFuture ;
562- }
563-
564- @ Override
565- public CompletableFuture <com .ibm .cloud .sdk .core .http .Response <T >> rxWithDetails () {
566- final CompletableFuture <com .ibm .cloud .sdk .core .http .Response <T >> completableFuture
567- = new CompletableFuture <>();
568-
569- call .enqueue (new Callback () {
570- @ Override
571- public void onFailure (Call call , IOException e ) {
572- completableFuture .completeExceptionally (e );
573- }
574-
575- @ Override
576- public void onResponse (Call call , Response response ) {
577- try {
578- T responseModel = processServiceCall (converter , response );
579- completableFuture .complete (new com .ibm .cloud .sdk .core .http .Response <>(responseModel , response ));
580- } catch (Exception e ) {
581- completableFuture .completeExceptionally (e );
582- }
516+ public com .ibm .cloud .sdk .core .http .Response <T > call () throws Exception {
517+ Response response = call .execute ();
518+ T responseModel = processServiceCall (converter , response );
519+ return new com .ibm .cloud .sdk .core .http .Response <>(responseModel , response );
583520 }
584521 });
585-
586- return completableFuture ;
587522 }
588523
589524 @ Override
0 commit comments