19
19
import com .ibm .cloud .sdk .core .http .ResponseConverter ;
20
20
import com .ibm .cloud .sdk .core .http .ServiceCall ;
21
21
import com .ibm .cloud .sdk .core .http .ServiceCallback ;
22
- import com .ibm .cloud .sdk .core .http .ServiceCallbackWithDetails ;
23
22
import com .ibm .cloud .sdk .core .service .exception .BadRequestException ;
24
23
import com .ibm .cloud .sdk .core .service .exception .ConflictException ;
25
24
import com .ibm .cloud .sdk .core .service .exception .ForbiddenException ;
35
34
import com .ibm .cloud .sdk .core .service .security .IamTokenManager ;
36
35
import com .ibm .cloud .sdk .core .util .CredentialUtils ;
37
36
import com .ibm .cloud .sdk .core .util .RequestUtils ;
38
- import jersey . repackaged . jsr166e . CompletableFuture ;
37
+ import io . reactivex . Single ;
39
38
import okhttp3 .Call ;
40
39
import okhttp3 .Callback ;
41
40
import okhttp3 .Credentials ;
47
46
48
47
import java .io .IOException ;
49
48
import java .util .Map ;
49
+ import java .util .concurrent .Callable ;
50
50
import java .util .logging .Logger ;
51
51
import java .util .regex .Pattern ;
52
52
@@ -479,47 +479,18 @@ public ServiceCall<T> addHeader(String name, String value) {
479
479
}
480
480
481
481
@ Override
482
- public T execute () {
482
+ public com . ibm . cloud . sdk . core . http . Response < T > execute () {
483
483
try {
484
484
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 );
497
487
} catch (IOException e ) {
498
488
throw new RuntimeException (e );
499
489
}
500
490
}
501
491
502
492
@ Override
503
493
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 ) {
523
494
call .enqueue (new Callback () {
524
495
@ Override
525
496
public void onFailure (Call call , IOException e ) {
@@ -539,51 +510,15 @@ public void onResponse(Call call, Response response) {
539
510
}
540
511
541
512
@ 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 >>() {
546
515
@ 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 );
583
520
}
584
521
});
585
-
586
- return completableFuture ;
587
522
}
588
523
589
524
@ Override
0 commit comments