com.amazonaws.services.s3.model.BucketTaggingConfiguration#org.cloudfoundry.community.servicebroker.model.ServiceInstance源码实例Demo

下面列出了com.amazonaws.services.s3.model.BucketTaggingConfiguration#org.cloudfoundry.community.servicebroker.model.ServiceInstance 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: postgresql-cf-service-broker   文件: Database.java
public ServiceInstance findServiceInstance(String instanceId) throws SQLException {
    Utils.checkValidUUID(instanceId);

    Map<Integer, String> parameterMap = new HashMap<Integer, String>();
    parameterMap.put(1, instanceId);

    Map<String, String> result = PostgreSQLDatabase.executePreparedSelect("SELECT * FROM service WHERE serviceinstanceid = ?", parameterMap);

    String serviceDefinitionId = result.get("servicedefinitionid");
    String organizationGuid = result.get("organizationguid");
    String planId = result.get("planid");
    String spaceGuid = result.get("spaceguid");

    CreateServiceInstanceRequest wrapper = new CreateServiceInstanceRequest(serviceDefinitionId, planId, organizationGuid, spaceGuid).withServiceInstanceId(instanceId);
    return new ServiceInstance(wrapper);
}
 
@Override
public ServiceInstance createServiceInstance(CreateServiceInstanceRequest createServiceInstanceRequest)
        throws ServiceInstanceExistsException, ServiceBrokerException {
    String serviceInstanceId = createServiceInstanceRequest.getServiceInstanceId();
    String serviceId = createServiceInstanceRequest.getServiceDefinitionId();
    String planId = createServiceInstanceRequest.getPlanId();
    String organizationGuid = createServiceInstanceRequest.getOrganizationGuid();
    String spaceGuid = createServiceInstanceRequest.getSpaceGuid();
    try {
        db.createDatabaseForInstance(serviceInstanceId, serviceId, planId, organizationGuid, spaceGuid);
        role.createRoleForInstance(serviceInstanceId);
    } catch (SQLException e) {
        logger.error("Error while creating service instance '" + serviceInstanceId + "'", e);
        throw new ServiceBrokerException(e.getMessage());
    }
    return new ServiceInstance(createServiceInstanceRequest);
}
 
源代码3 项目: s3-cf-service-broker   文件: S3.java
private ServiceInstance createServiceInstance(BucketTaggingConfiguration taggingConfiguration) {
    // While the Java API has multiple TagSets, it would appear from
    // http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTtagging.html
    // that only one TagSet is supported.
    TagSet tagSet = taggingConfiguration.getTagSet();
    String serviceInstanceId = tagSet.getTag("serviceInstanceId");
    if (serviceInstanceId == null) {
        // could occur if someone used this broker AWS ID to a bucket
        // outside of the broker process
        return null;
    }
    String serviceDefinitionId = tagSet.getTag("serviceDefinitionId");
    String planId = tagSet.getTag("planId");
    String organizationGuid = tagSet.getTag("organizationGuid");
    String spaceGuid = tagSet.getTag("spaceGuid");
    ServiceInstance serviceInstance = new ServiceInstance(serviceInstanceId, serviceDefinitionId, planId,
            organizationGuid, spaceGuid, null);
    return serviceInstance;
}
 
源代码4 项目: s3-cf-service-broker   文件: BasicPlan.java
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);
}
 
@Override
public ServiceInstance deleteServiceInstance(DeleteServiceInstanceRequest deleteServiceInstanceRequest)
        throws ServiceBrokerException {
    String serviceInstanceId = deleteServiceInstanceRequest.getServiceInstanceId();
    ServiceInstance instance = getServiceInstance(serviceInstanceId);

    try {
        db.deleteDatabase(serviceInstanceId);
        role.deleteRole(serviceInstanceId);
    } catch (SQLException e) {
        logger.error("Error while deleting service instance '" + serviceInstanceId + "'", e);
        throw new ServiceBrokerException(e.getMessage());
    }
    return instance;
}
 
@Override
public ServiceInstance getServiceInstance(String id) {
    try {
        return db.findServiceInstance(id);
    } catch (SQLException e) {
        logger.error("Error while finding service instance '" + id + "'", e);
        return null;
    }
}
 
public static ServiceInstance getServiceInstance() {
	return new ServiceInstance(new CreateServiceInstanceRequest(
			"service-one-id", 
			"plan-one-id", 
			DataFixture.getOrgOneGuid(), 
			DataFixture.getSpaceOneGuid(), 
			false,
			ParametersFixture.getParameters())
		.withServiceInstanceId("service-instnce-one-id"))
		.withDashboardUrl("dashboard_url");
			
}
 
public static ServiceInstance getServiceInstanceTwo() {
	return new ServiceInstance(new CreateServiceInstanceRequest(
			"service-two-id", 
			"plan-two-id", 
			DataFixture.getOrgOneGuid(), 
			DataFixture.getSpaceOneGuid(),
			false,
			ParametersFixture.getParameters())
		.withServiceInstanceId("service-instnce-two-id"))
		.withDashboardUrl("dashboard_url");

}
 
源代码9 项目: s3-cf-service-broker   文件: S3.java
public ServiceInstance findServiceInstance(String instanceId) {
    String bucketName = getBucketNameForInstance(instanceId);
    if (s3.doesBucketExist(bucketName)) {
        BucketTaggingConfiguration taggingConfiguration = s3.getBucketTaggingConfiguration(bucketName);
        return createServiceInstance(taggingConfiguration);
    }
    return null;
}
 
源代码10 项目: s3-cf-service-broker   文件: S3.java
public List<ServiceInstance> getAllServiceInstances() {
    List<ServiceInstance> serviceInstances = Lists.newArrayList();
    for (Bucket bucket : s3.listBuckets()) {
        BucketTaggingConfiguration taggingConfiguration = s3.getBucketTaggingConfiguration(bucket.getName());
        ServiceInstance serviceInstance = createServiceInstance(taggingConfiguration);
        serviceInstances.add(serviceInstance);
    }
    return serviceInstances;
}
 
源代码11 项目: s3-cf-service-broker   文件: BasicPlan.java
public ServiceInstance createServiceInstance(ServiceDefinition service, String serviceInstanceId, String planId,
                                             String organizationGuid, String spaceGuid) {
    Bucket bucket = s3.createBucketForInstance(serviceInstanceId, service, planId, organizationGuid, spaceGuid);
    iam.createGroupForInstance(serviceInstanceId, bucket.getName());
    iam.applyGroupPolicyForInstance(serviceInstanceId, bucket.getName());
    return new ServiceInstance(serviceInstanceId, service.getId(), planId, organizationGuid, spaceGuid, null);
}
 
源代码12 项目: s3-cf-service-broker   文件: BasicPlan.java
public ServiceInstance deleteServiceInstance(String id) {
    ServiceInstance instance = s3.findServiceInstance(id);
    // TODO we need to make these deletes idempotent so we can handle retries on error
    iam.deleteGroupPolicyForInstance(id);
    iam.deleteGroupForInstance(id);
    s3.emptyBucket(id);
    s3.deleteBucket(id);
    return instance;
}
 
源代码13 项目: s3-cf-service-broker   文件: BasicPlan.java
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);
}
 
源代码14 项目: postgresql-cf-service-broker   文件: Database.java
public List<ServiceInstance> getAllServiceInstances() {
    return Collections.emptyList();
}
 
@Override
public ServiceInstance updateServiceInstance(UpdateServiceInstanceRequest updateServiceInstanceRequest)
        throws ServiceInstanceUpdateNotSupportedException, ServiceBrokerException, ServiceInstanceDoesNotExistException {
    throw new IllegalStateException("Not implemented");
}
 
public ServiceInstanceExistsException(ServiceInstance instance) {
	super("ServiceInstance with the given ID already exists: " +
			"ServiceInstance.id = " + instance.getServiceInstanceId() +
			", Service.id = " + instance.getServiceDefinitionId());
}
 
public static List<ServiceInstance> getAllServiceInstances() {
	List<ServiceInstance> instances = new ArrayList<ServiceInstance>();
	instances.add(getServiceInstance());
	instances.add(getServiceInstanceTwo());
	return instances;
}
 
public static ServiceInstance getAsyncServiceInstance() {
	return new ServiceInstance(
			new CreateServiceInstanceRequest(null, null, null, null, true, null))
			.withDashboardUrl(null);
}
 
@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);
}
 
@Override
public ServiceInstanceBinding deleteServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
        String serviceId, String planId) throws ServiceBrokerException {
    return plan.deleteServiceInstanceBinding(bindingId, serviceInstance, serviceId, planId);
}
 
@Override
public ServiceInstance createServiceInstance(ServiceDefinition service, String serviceInstanceId, String planId,
        String organizationGuid, String spaceGuid) throws ServiceInstanceExistsException, ServiceBrokerException {
    return plan.createServiceInstance(service, serviceInstanceId, planId, organizationGuid, spaceGuid);
}
 
@Override
public ServiceInstance deleteServiceInstance(String id, String serviceId, String planId)
        throws ServiceBrokerException {
    return plan.deleteServiceInstance(id);
}
 
@Override
public List<ServiceInstance> getAllServiceInstances() {
    return plan.getAllServiceInstances();
}
 
@Override
public ServiceInstance getServiceInstance(String id) {
    return plan.getServiceInstance(id);
}
 
源代码25 项目: s3-cf-service-broker   文件: Plan.java
ServiceInstance createServiceInstance(ServiceDefinition service, String serviceInstanceId, String planId,
String organizationGuid, String spaceGuid);
 
源代码26 项目: s3-cf-service-broker   文件: Plan.java
ServiceInstanceBinding createServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
String serviceId, String planId, String appGuid);
 
源代码27 项目: s3-cf-service-broker   文件: Plan.java
ServiceInstanceBinding deleteServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
String serviceId, String planId) throws ServiceBrokerException;
 
源代码28 项目: s3-cf-service-broker   文件: BasicPlan.java
public List<ServiceInstance> getAllServiceInstances() {
    return s3.getAllServiceInstances();
}
 
源代码29 项目: s3-cf-service-broker   文件: BasicPlan.java
public ServiceInstance getServiceInstance(String id) {
    return s3.findServiceInstance(id);
}
 
源代码30 项目: s3-cf-service-broker   文件: Plan.java
ServiceInstance deleteServiceInstance(String id);