Skip to content

Commit

Permalink
Added binding-name parameter
Browse files Browse the repository at this point in the history
Formatting
  • Loading branch information
Noeva authored and IvanBorislavovDimitrov committed Jul 4, 2024
1 parent 8928d08 commit d9bd980
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,25 @@ public interface CloudControllerClient {
/**
* Associate (provision) a service with an application.
*
* @param bindingName the binding name
* @param applicationName the application name
* @param serviceInstanceName the service instance name
* @return job id for async polling if present
*/
Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName);
Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName);

/**
* Associate (provision) a service with an application.
*
* @param bindingName the binding name
* @param applicationName the application name
* @param serviceInstanceName the service instance name
* @param parameters the binding parameters
* @param updateServicesCallback callback used for error handling
* @return job id for async polling if present
*/
Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName, Map<String, Object> parameters,
ApplicationServicesUpdateCallback updateServicesCallback);
Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName,
Map<String, Object> parameters, ApplicationServicesUpdateCallback updateServicesCallback);

/**
* Create application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ public void addRoute(String host, String domainName, String path) {
}

@Override
public Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName) {
return handleExceptions(() -> delegate.bindServiceInstance(applicationName, serviceInstanceName));
public Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName) {
return handleExceptions(() -> delegate.bindServiceInstance(bindingName, applicationName, serviceInstanceName));
}

@Override
public Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName, Map<String, Object> parameters,
ApplicationServicesUpdateCallback updateServicesCallback) {
public Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName,
Map<String, Object> parameters, ApplicationServicesUpdateCallback updateServicesCallback) {
try {
return handleExceptions(() -> delegate.bindServiceInstance(applicationName, serviceInstanceName, parameters));
return handleExceptions(() -> delegate.bindServiceInstance(bindingName, applicationName, serviceInstanceName, parameters));
} catch (CloudOperationException e) {
updateServicesCallback.onError(e, applicationName, serviceInstanceName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public interface CloudControllerRestClient {

void addRoute(String host, String domainName, String path);

Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName);
Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName);

Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName, Map<String, Object> parameters);
Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName, Map<String, Object> parameters);

void createApplication(ApplicationToCreateDto applicationToCreateDto);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@

/**
* Abstract implementation of the CloudControllerClient intended to serve as the base.
*
*/
public class CloudControllerRestClientImpl implements CloudControllerRestClient {

Expand Down Expand Up @@ -270,16 +269,18 @@ public void addRoute(String host, String domainName, String path) {
}

@Override
public Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName) {
return bindServiceInstance(applicationName, serviceInstanceName, null);
public Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName) {
return bindServiceInstance(bindingName, applicationName, serviceInstanceName, null);
}

@Override
public Optional<String> bindServiceInstance(String applicationName, String serviceInstanceName, Map<String, Object> parameters) {
public Optional<String> bindServiceInstance(String bindingName, String applicationName, String serviceInstanceName,
Map<String, Object> parameters) {
UUID applicationGuid = getRequiredApplicationGuid(applicationName);
UUID serviceInstanceGuid = getRequiredServiceInstanceGuid(serviceInstanceName);

var createBindingRequest = CreateServiceBindingRequest.builder()
.name(bindingName)
.type(ServiceBindingType.APPLICATION)
.relationships(ServiceBindingRelationships.builder()
.application(buildToOneRelationship(applicationGuid))
Expand Down

0 comments on commit d9bd980

Please sign in to comment.