@@ -395,8 +395,7 @@ private void updateApplicationProcess(UUID applicationGuid, Staging staging) {
395395 if (staging .getHealthCheckType () != null ) {
396396 updateProcessRequestBuilder .healthCheck (buildHealthCheck (staging ));
397397 }
398- if (staging .isReadinessHealthCheckEnabled () != null && staging .isReadinessHealthCheckEnabled ()
399- && staging .getReadinessHealthCheckType () != null ) {
398+ if (staging .getReadinessHealthCheckType () != null ) {
400399 updateProcessRequestBuilder .readinessHealthCheck (buildReadinessHealthCheck (staging ));
401400 }
402401 delegate .processes ()
@@ -678,7 +677,8 @@ public Optional<String> deleteServiceBinding(String serviceInstanceName, String
678677 if (serviceKey == null ) {
679678 throw new CloudOperationException (HttpStatus .NOT_FOUND , "Not Found" , "Service key " + serviceKeyName + " not found." );
680679 }
681- return doDeleteServiceBinding (serviceKey .getGuid ());
680+ return doDeleteServiceBindings (List .of (serviceKey .getGuid ())).stream ()
681+ .findFirst ();
682682 }
683683
684684 @ Override
@@ -913,9 +913,9 @@ public List<CloudServiceBinding> getAppBindings(UUID applicationGuid) {
913913 }
914914
915915 @ Override
916- public CloudServiceBinding getServiceBindingForApplication (UUID applicationId , UUID serviceInstanceGuid ) {
917- return fetch (() -> getServiceBindingResourceByApplicationGuidAndServiceInstanceGuid (applicationId , serviceInstanceGuid ),
918- ImmutableRawCloudServiceBinding ::of );
916+ public List < CloudServiceBinding > getServiceBindingsForApplication (UUID applicationId , UUID serviceInstanceGuid ) {
917+ return fetchList (() -> getServiceBindingResourcesByApplicationGuidAndServiceInstanceGuid (applicationId , serviceInstanceGuid ),
918+ ImmutableRawCloudServiceBinding ::of );
919919 }
920920
921921 @ Override
@@ -1258,7 +1258,7 @@ public void stopApplication(String applicationName) {
12581258 }
12591259
12601260 @ Override
1261- public Optional <String > unbindServiceInstance (String applicationName , String serviceInstanceName ) {
1261+ public List <String > unbindServiceInstance (String applicationName , String serviceInstanceName ) {
12621262 UUID applicationGuid = getRequiredApplicationGuid (applicationName );
12631263 UUID serviceInstanceGuid = getRequiredServiceInstanceGuid (serviceInstanceName );
12641264
@@ -1267,11 +1267,12 @@ public Optional<String> unbindServiceInstance(String applicationName, String ser
12671267
12681268 @ Override
12691269 public Optional <String > deleteServiceBinding (UUID serviceBindingGuid ) {
1270- return doDeleteServiceBinding (serviceBindingGuid );
1270+ return doDeleteServiceBindings (List .of (serviceBindingGuid )).stream ()
1271+ .findFirst ();
12711272 }
12721273
12731274 @ Override
1274- public Optional <String > unbindServiceInstance (UUID applicationGuid , UUID serviceInstanceGuid ) {
1275+ public List <String > unbindServiceInstance (UUID applicationGuid , UUID serviceInstanceGuid ) {
12751276 return doUnbindServiceInstance (applicationGuid , serviceInstanceGuid );
12761277 }
12771278
@@ -1737,16 +1738,16 @@ private Flux<? extends ServiceBindingResource> getServiceBindingResourcesByServi
17371738 .list (pageRequestSupplier .apply (page )));
17381739 }
17391740
1740- private Mono <? extends ServiceBindingResource > getServiceBindingResourceByApplicationGuidAndServiceInstanceGuid (UUID applicationGuid ,
1741- UUID serviceInstanceGuid ) {
1741+ private Flux <? extends ServiceBindingResource > getServiceBindingResourcesByApplicationGuidAndServiceInstanceGuid (UUID applicationGuid ,
1742+ UUID serviceInstanceGuid ) {
17421743 IntFunction <ListServiceBindingsRequest > pageRequestSupplier = page -> ListServiceBindingsRequest .builder ()
17431744 .applicationId (
17441745 applicationGuid .toString ())
17451746 .serviceInstanceId (
17461747 serviceInstanceGuid .toString ())
17471748 .page (page )
17481749 .build ();
1749- return getApplicationServiceBindingResources (pageRequestSupplier ). singleOrEmpty () ;
1750+ return getApplicationServiceBindingResources (pageRequestSupplier );
17501751 }
17511752
17521753 private Flux <? extends ServiceBindingResource > getServiceBindingResourcesByApplicationGuid (UUID applicationGuid ) {
@@ -2036,23 +2037,47 @@ private void doDeleteServiceInstance(UUID serviceInstanceGuid) {
20362037 .block ();
20372038 }
20382039
2039- private Optional <String > doUnbindServiceInstance (UUID applicationGuid , UUID serviceInstanceGuid ) {
2040- UUID serviceBindingGuid = getServiceBindingGuid (applicationGuid , serviceInstanceGuid );
2041- if (serviceBindingGuid == null ) {
2040+ private List <String > doUnbindServiceInstance (UUID applicationGuid , UUID serviceInstanceGuid ) {
2041+ List < UUID > serviceBindingGuids = getServiceBindingGuids (applicationGuid , serviceInstanceGuid );
2042+ if (serviceBindingGuids . isEmpty () ) {
20422043 throw new CloudOperationException (HttpStatus .NOT_FOUND , "Not Found" ,
20432044 "Service binding between service with GUID " + serviceInstanceGuid
20442045 + " and application with GUID " + applicationGuid + " not found." );
20452046 }
2046- return doDeleteServiceBinding ( serviceBindingGuid );
2047+ return doDeleteServiceBindings ( serviceBindingGuids );
20472048 }
20482049
2049- private Optional <String > doDeleteServiceBinding (UUID guid ) {
2050- String jobId = delegate .serviceBindingsV3 ()
2051- .delete (DeleteServiceBindingRequest .builder ()
2052- .serviceBindingId (guid .toString ())
2053- .build ())
2054- .block ();
2055- return Optional .ofNullable (jobId );
2050+ private List <String > doDeleteServiceBindings (List <UUID > guids ) {
2051+ List <String > jobIds = new ArrayList <>();
2052+ List <AbstractCloudFoundryException > errors = new ArrayList <>();
2053+ for (UUID guid : guids ) {
2054+ try {
2055+ Optional .ofNullable (deleteSingleServiceBinding (guid ))
2056+ .ifPresent (jobIds ::add );
2057+ } catch (AbstractCloudFoundryException e ) {
2058+ errors .add (e );
2059+ }
2060+ }
2061+ throwOnErrors (errors );
2062+ return jobIds ;
2063+ }
2064+
2065+ private String deleteSingleServiceBinding (UUID guid ) {
2066+ return delegate .serviceBindingsV3 ()
2067+ .delete (DeleteServiceBindingRequest .builder ()
2068+ .serviceBindingId (guid .toString ())
2069+ .build ())
2070+ .block ();
2071+ }
2072+
2073+ private void throwOnErrors (List <AbstractCloudFoundryException > errors ) {
2074+ if (errors .isEmpty ()) {
2075+ return ;
2076+ }
2077+ RuntimeException first = errors .get (0 );
2078+ errors .subList (1 , errors .size ())
2079+ .forEach (first ::addSuppressed );
2080+ throw first ;
20562081 }
20572082
20582083 private CloudDomain findDomainByName (String name , boolean required ) {
@@ -2464,9 +2489,10 @@ private UUID getRouteGuid(UUID domainGuid, String host, String path) {
24642489 return getGuid (routeEntitiesResource .get (0 ));
24652490 }
24662491
2467- private UUID getServiceBindingGuid (UUID applicationGuid , UUID serviceInstanceGuid ) {
2468- return getServiceBindingResourceByApplicationGuidAndServiceInstanceGuid (applicationGuid , serviceInstanceGuid ).map (this ::getGuid )
2469- .block ();
2492+ private List <UUID > getServiceBindingGuids (UUID applicationGuid , UUID serviceInstanceGuid ) {
2493+ return getServiceBindingResourcesByApplicationGuidAndServiceInstanceGuid (applicationGuid , serviceInstanceGuid ).map (this ::getGuid )
2494+ .collectList ()
2495+ .block ();
24702496 }
24712497
24722498 private void processAsyncUploadInBackground (CloudPackage cloudPackage , UploadStatusCallback callback ) {
0 commit comments