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

The following examples show how to use org.cloudfoundry.community.servicebroker.model.ServiceDefinition. 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: PostgreSQLServiceBrokerV2IntegrationTests.java    From postgresql-cf-service-broker with Apache License 2.0 6 votes vote down vote up
/**
 * cf marketplace
 * cf create-service-broker
 * <p>
 * Fetch Catalog (GET /v2/catalog)
 */

@Override
@Test
public void case1_fetchCatalogSucceedsWithCredentials() throws Exception {
    // same as super code, but we need the response here
    ValidatableResponse response = given().auth().basic(username, password).header(apiVersionHeader).when().get(fetchCatalogPath).then().statusCode(HttpStatus.SC_OK);

    BrokerConfiguration brokerConfiguration = new BrokerConfiguration();
    ServiceDefinition serviceDefinition = brokerConfiguration.catalog().getServiceDefinitions().get(0);

    response.body("services[0].id", equalTo(serviceDefinition.getId()));
    response.body("services[0].name", equalTo(serviceDefinition.getName()));
    response.body("services[0].description", equalTo(serviceDefinition.getDescription()));
    response.body("services[0].requires", equalTo(serviceDefinition.getRequires()));
    response.body("services[0].tags", equalTo(serviceDefinition.getTags()));

    List<String> planIds = new ArrayList<String>();
    for(Plan plan: serviceDefinition.getPlans()) {
        planIds.add(plan.getId());
    }
    response.body("services[0].plans.id", equalTo(planIds));
}
 
Example #2
Source File: S3.java    From s3-cf-service-broker with Apache License 2.0 6 votes vote down vote up
public Bucket createBucketForInstance(String instanceId, ServiceDefinition service, String planId,
        String organizationGuid, String spaceGuid) {
    String bucketName = getBucketNameForInstance(instanceId);
    logger.info("Creating bucket '{}' for serviceInstanceId '{}'", bucketName, instanceId);
    Bucket bucket = s3.createBucket(bucketName, Region.fromValue(region));

    // TODO allow for additional, custom tagging options
    BucketTaggingConfiguration bucketTaggingConfiguration = new BucketTaggingConfiguration();
    TagSet tagSet = new TagSet();
    tagSet.setTag("serviceInstanceId", instanceId);
    tagSet.setTag("serviceDefinitionId", service.getId());
    tagSet.setTag("planId", planId);
    tagSet.setTag("organizationGuid", organizationGuid);
    tagSet.setTag("spaceGuid", spaceGuid);
    bucketTaggingConfiguration.withTagSets(tagSet);
    s3.setBucketTaggingConfiguration(bucket.getName(), bucketTaggingConfiguration);

    return bucket;
}
 
Example #3
Source File: ServiceInstanceFixture.java    From spring-boot-cf-service-broker with Apache License 2.0 5 votes vote down vote up
public static CreateServiceInstanceRequest getCreateServiceInstanceRequest() {
	ServiceDefinition service = ServiceFixture.getService();
	return new CreateServiceInstanceRequest(
			service.getId(), 
			service.getPlans().get(0).getId(),
			DataFixture.getOrgOneGuid(),
			DataFixture.getSpaceOneGuid(),
			false,
			ParametersFixture.getParameters()
	);
}
 
Example #4
Source File: ServiceFixture.java    From spring-boot-cf-service-broker with Apache License 2.0 5 votes vote down vote up
public static ServiceDefinition getService() {
	return new ServiceDefinition(
			"service-one-id", 
			"Service One", 
			"Description for Service One", 
			true,
			PlanFixture.getAllPlans());
}
 
Example #5
Source File: BeanCatalogServiceTest.java    From spring-boot-cf-service-broker with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	serviceDefinition = new ServiceDefinition(SVC_DEF_ID, "Name", "Description", true, null);
	List<ServiceDefinition> defs = new ArrayList<ServiceDefinition>();
	defs.add(serviceDefinition);
	catalog = new Catalog(defs);	
	service = new BeanCatalogService(catalog);
}
 
Example #6
Source File: BrokerConfiguration.java    From s3-cf-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public Catalog catalog() throws IOException {
    ServiceDefinition serviceDefinition = new ServiceDefinition("s3", "amazon-s3",
            "Amazon S3 is storage for the Internet.", true, getPlans(), getTags(), getServiceDefinitionMetadata(),
            Arrays.asList("syslog_drain"), null);
    return new Catalog(Arrays.asList(serviceDefinition));
}
 
Example #7
Source File: BasicPlan.java    From s3-cf-service-broker with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #8
Source File: BrokerConfiguration.java    From postgresql-cf-service-broker with Apache License 2.0 4 votes vote down vote up
@Bean
public Catalog catalog() throws IOException {
    ServiceDefinition serviceDefinition = new ServiceDefinition("pg", "PostgreSQL", "PostgreSQL on shared instance.",
            true, false, getPlans(), getTags(), getServiceDefinitionMetadata(), Arrays.asList("syslog_drain"), null);
    return new Catalog(Arrays.asList(serviceDefinition));
}
 
Example #9
Source File: BeanCatalogService.java    From spring-boot-cf-service-broker with Apache License 2.0 4 votes vote down vote up
private void initializeMap() {
	for (ServiceDefinition def: catalog.getServiceDefinitions()) {
		serviceDefs.put(def.getId(), def);
	}
}
 
Example #10
Source File: BeanCatalogService.java    From spring-boot-cf-service-broker with Apache License 2.0 4 votes vote down vote up
@Override
public ServiceDefinition getServiceDefinition(String serviceId) {
	return serviceDefs.get(serviceId);
}
 
Example #11
Source File: ServiceInstanceFixture.java    From spring-boot-cf-service-broker with Apache License 2.0 4 votes vote down vote up
public static UpdateServiceInstanceRequest getUpdateServiceInstanceRequest() {
	ServiceDefinition service = ServiceFixture.getService();
	return new UpdateServiceInstanceRequest(service.getPlans().get(0).getId(), false,
			ParametersFixture.getParameters());
}
 
Example #12
Source File: ServiceFixture.java    From spring-boot-cf-service-broker with Apache License 2.0 4 votes vote down vote up
public static List<ServiceDefinition> getAllServices() {
	List<ServiceDefinition> services = new ArrayList<ServiceDefinition>();
	services.add(ServiceFixture.getService());
	return services;
}
 
Example #13
Source File: S3ServiceInstanceService.java    From s3-cf-service-broker with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #14
Source File: Plan.java    From s3-cf-service-broker with Apache License 2.0 4 votes vote down vote up
ServiceInstance createServiceInstance(ServiceDefinition service, String serviceInstanceId, String planId,
String organizationGuid, String spaceGuid);
 
Example #15
Source File: CatalogService.java    From spring-boot-cf-service-broker with Apache License 2.0 2 votes vote down vote up
/**
 * @param serviceId  The id of the service in the catalog
 * @return The service definition or null if it doesn't exist
 */
ServiceDefinition getServiceDefinition(String serviceId);