org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding Java Examples

The following examples show how to use org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostgreSQLServiceInstanceBindingService.java    From postgresql-cf-service-broker with Apache License 2.0 6 votes vote down vote up
@Override
public ServiceInstanceBinding createServiceInstanceBinding(CreateServiceInstanceBindingRequest createServiceInstanceBindingRequest)
        throws ServiceInstanceBindingExistsException, ServiceBrokerException {
    String bindingId = createServiceInstanceBindingRequest.getBindingId();
    String serviceInstanceId = createServiceInstanceBindingRequest.getServiceInstanceId();
    String appGuid = createServiceInstanceBindingRequest.getAppGuid();
    String passwd = "";

    try {
        passwd = this.role.bindRoleToDatabase(serviceInstanceId);
    } catch (SQLException e) {
        logger.error("Error while creating service instance binding '" + bindingId + "'", e);
        throw new ServiceBrokerException(e.getMessage());
    }

    String dbURL = String.format("postgres://%s:%s@%s:%d/%s", serviceInstanceId, passwd, PostgreSQLDatabase.getDatabaseHost(), PostgreSQLDatabase.getDatabasePort(), serviceInstanceId);

    Map<String, Object> credentials = new HashMap<String, Object>();
    credentials.put("uri", dbURL);

    return new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, appGuid);
}
 
Example #2
Source File: BasicPlan.java    From s3-cf-service-broker with Apache License 2.0 6 votes vote down vote up
public ServiceInstanceBinding createServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
                                                           String serviceId, String planId, String appGuid) {
    User user = iam.createUserForBinding(bindingId);
    AccessKey accessKey = iam.createAccessKey(user);
    // TODO create password and add to credentials
    iam.addUserToGroup(user, iam.getGroupNameForInstance(serviceInstance.getId()));
    String bucketName = s3.getBucketNameForInstance(serviceInstance.getId());
    Map<String, Object> credentials = new HashMap<String, Object>();
    credentials.put("bucket", bucketName);
    credentials.put("username", user.getUserName());
    credentials.put("access_key_id", accessKey.getAccessKeyId());
    credentials.put("secret_access_key", accessKey.getSecretAccessKey());
    credentials.put("host", AMAZON_S3_HOST);
    credentials.put("uri", this.generateUri(accessKey.getAccessKeyId(), accessKey.getSecretAccessKey(), bucketName));
    return new ServiceInstanceBinding(bindingId, serviceInstance.getId(), credentials, null, appGuid);
}
 
Example #3
Source File: PostgreSQLServiceInstanceBindingService.java    From postgresql-cf-service-broker with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceInstanceBinding deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest deleteServiceInstanceBindingRequest)
        throws ServiceBrokerException {
    String serviceInstanceId = deleteServiceInstanceBindingRequest.getInstance().getServiceInstanceId();
    String bindingId = deleteServiceInstanceBindingRequest.getBindingId();
    try {
        this.role.unBindRoleFromDatabase(serviceInstanceId);
    } catch (SQLException e) {
        logger.error("Error while deleting service instance binding '" + bindingId + "'", e);
        throw new ServiceBrokerException(e.getMessage());
    }
    return new ServiceInstanceBinding(bindingId, serviceInstanceId, null, null, null);
}
 
Example #4
Source File: BasicPlan.java    From s3-cf-service-broker with Apache License 2.0 5 votes vote down vote up
public ServiceInstanceBinding deleteServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
                                                           String serviceId, String planId) throws ServiceBrokerException {
    // TODO make operations idempotent so we can handle retries on error
    iam.removeUserFromGroupForInstance(bindingId, serviceInstance.getId());
    iam.deleteUserAccessKeysForBinding(bindingId);
    iam.deleteUserForBinding(bindingId);
    return new ServiceInstanceBinding(bindingId, serviceInstance.getId(), null, null, null);
}
 
Example #5
Source File: ServiceInstanceBindingExistsException.java    From spring-boot-cf-service-broker with Apache License 2.0 4 votes vote down vote up
public ServiceInstanceBindingExistsException(ServiceInstanceBinding binding) {
	super("ServiceInstanceBinding already exists: serviceInstanceBinding.id = "
			+ binding.getId()
			+ ", serviceInstance.id = " + binding.getServiceInstanceId());
}
 
Example #6
Source File: S3ServiceInstanceBindingService.java    From s3-cf-service-broker with Apache License 2.0 4 votes vote down vote up
@Override
public ServiceInstanceBinding createServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
        String serviceId, String planId, String appGuid) throws ServiceInstanceBindingExistsException,
        ServiceBrokerException {
    return plan.createServiceInstanceBinding(bindingId, serviceInstance, serviceId, planId, appGuid);
}
 
Example #7
Source File: S3ServiceInstanceBindingService.java    From s3-cf-service-broker with Apache License 2.0 4 votes vote down vote up
@Override
public ServiceInstanceBinding deleteServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
        String serviceId, String planId) throws ServiceBrokerException {
    return plan.deleteServiceInstanceBinding(bindingId, serviceInstance, serviceId, planId);
}
 
Example #8
Source File: S3ServiceInstanceBindingService.java    From s3-cf-service-broker with Apache License 2.0 4 votes vote down vote up
@Override
public ServiceInstanceBinding getServiceInstanceBinding(String id) {
    throw new IllegalStateException("Not implemented");
}
 
Example #9
Source File: Plan.java    From s3-cf-service-broker with Apache License 2.0 4 votes vote down vote up
ServiceInstanceBinding createServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
String serviceId, String planId, String appGuid);
 
Example #10
Source File: Plan.java    From s3-cf-service-broker with Apache License 2.0 4 votes vote down vote up
ServiceInstanceBinding deleteServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
String serviceId, String planId) throws ServiceBrokerException;