本文整理汇总了Java中org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse类的典型用法代码示例。如果您正苦于以下问题:Java CreateServiceInstanceBindingResponse类的具体用法?Java CreateServiceInstanceBindingResponse怎么用?Java CreateServiceInstanceBindingResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateServiceInstanceBindingResponse类属于org.springframework.cloud.servicebroker.model包,在下文中一共展示了CreateServiceInstanceBindingResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(
CreateServiceInstanceBindingRequest request)
throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
try {
BindingWorkflow workflow = getWorkflow(request);
LOG.info("creating binding");
workflow.checkIfUserExists();
String secretKey = workflow.createBindingUser();
LOG.info("building binding response");
Map<String, Object> credentials = workflow.getCredentials(secretKey,
request.getParameters());
ServiceInstanceBinding binding = workflow.getBinding(credentials);
LOG.info("saving binding...");
repository.save(binding);
LOG.info("binding saved.");
return workflow.getResponse(credentials);
} catch (IOException | JAXBException | EcsManagementClientException e) {
throw new ServiceBrokerException(e);
}
}
示例2: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@PutMapping(value = {
"/{cfInstanceId}/v2/service_instances/{instanceId}/service_bindings/{bindingId}",
"/v2/service_instances/{instanceId}/service_bindings/{bindingId}"
})
public ResponseEntity<?> createServiceInstanceBinding(@PathVariable Map<String, String> pathVariables,
@PathVariable("instanceId") String serviceInstanceId,
@PathVariable("bindingId") String bindingId,
@RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation,
@RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString,
@Valid @RequestBody CreateServiceInstanceBindingRequest request) {
request.setServiceInstanceId(serviceInstanceId);
request.setBindingId(bindingId);
request.setServiceDefinition(getServiceDefinition(request.getServiceDefinitionId()));
setCommonRequestFields(request, pathVariables.get("cfInstanceId"), apiInfoLocation, originatingIdentityString);
log.debug("Creating a service instance binding: request={}", request);
CreateServiceInstanceBindingResponse response = serviceInstanceBindingService.createServiceInstanceBinding(request);
log.debug("Creating a service instance binding succeeded: serviceInstanceId={}, bindingId={}, response={}",
serviceInstanceId, bindingId, response);
return new ResponseEntity<>(response, response.isBindingExisted() ? HttpStatus.OK : HttpStatus.CREATED);
}
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry-service-broker,代码行数:25,代码来源:ServiceInstanceBindingController.java
示例3: newServiceInstanceBindingCreatedSuccessfully
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Test
public void newServiceInstanceBindingCreatedSuccessfully()
throws ServiceBrokerException, ServiceInstanceBindingExistsException {
when(admin.getCredentialsFromSensors(anyString(), anyString(), any(Predicate.class), any(Predicate.class), any(Predicate.class), any(Predicate.class))).thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
when(admin.hasEffector(anyString(), anyString(), anyString())).thenReturn(new AsyncResult<>(false));
when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of());
when(brooklynCatalogService.getServiceDefinition(anyString())).thenReturn(serviceDefinition);
when(serviceInstance.getEntityId()).thenReturn("entityId");
CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);
CreateServiceInstanceBindingResponse binding = bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));
assertNotNull(binding);
// TODO assert binding was completed successfully
//assertEquals(SVC_INST_BIND_ID, binding.getServiceBindingId());
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:18,代码来源:BrooklynServiceInstanceBindingServiceTest.java
示例4: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(final CreateServiceInstanceBindingRequest request) {
final String bindingId = request.getBindingId();
final String serviceInstanceId = request.getServiceInstanceId();
ServiceInstanceBinding binding = bindingRepository.findOne(bindingId);
if (binding != null) {
throw new ServiceInstanceBindingExistsException(serviceInstanceId, bindingId);
}
ServiceInstance instance = instanceRepository.findOne(serviceInstanceId);
if (instance == null) {
throw new CloudKarafkaServiceException("Instance don't exist :" + serviceInstanceId);
}
final Map<String, Object> credentials = new HashMap<String, Object>(){
{
put("brokers", instance.getCloudKarafkaBrokers());
put("ca", instance.getCloudKarafkaCa());
put("cert", instance.getCloudKarafkaCert());
put("id", instance.getCloudKarafkaId());
put("private_key", instance.getCloudKarafkaPrivateKey());
put("topic_prefix", instance.getCloudKarafkaTopicPrefix());
put("brokers",instance.getCloudKarafkaBrokers());
put("message",instance.getCloudKarafkaMessage());
}};
binding = new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, request.getBoundAppGuid());
bindingRepository.save(binding);
return new CreateServiceInstanceAppBindingResponse().withCredentials(credentials);
}
示例5: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) {
String bindingId = request.getBindingId();
String serviceInstanceId = request.getServiceInstanceId();
ServiceInstanceBinding binding = bindingRepository.findOne(bindingId);
if (binding != null) {
throw new ServiceInstanceBindingExistsException(serviceInstanceId, bindingId);
}
String database = serviceInstanceId;
String username = bindingId;
// TODO Password Generator
String password = "password";
// TODO check if user already exists in the DB
mongo.createUser(database, username, password);
Map<String, Object> credentials =
Collections.singletonMap("uri", (Object) mongo.getConnectionString(database, username, password));
binding = new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, request.getBoundAppGuid());
bindingRepository.save(binding);
return new CreateServiceInstanceAppBindingResponse().withCredentials(credentials);
}
示例6: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) {
preBinding(request);
final CreateServiceInstanceBindingRequest req = mapper.map(request);
final ResponseEntity<CreateServiceInstanceAppBindingResponse> response = client.createServiceInstanceBinding(req.getServiceInstanceId(), req.getBindingId(), req);
postBinding(request, response.getBody());
return response.getBody();
}
开发者ID:orange-cloudfoundry,项目名称:sec-group-broker-filter,代码行数:9,代码来源:ServiceInstanceBindingServiceProxy.java
示例7: format
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public String format(CreateServiceInstanceBindingResponse response, String... strings) {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writer().withDefaultPrettyPrinter().writeValueAsString(response);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
开发者ID:orange-cloudfoundry,项目名称:static-creds-broker,代码行数:10,代码来源:CreateServiceBindingResponseFormatter.java
示例8: newServiceInstanceBindingCreatedSuccessfullyWithBindEffector
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Test
public void newServiceInstanceBindingCreatedSuccessfullyWithBindEffector()
throws ServiceBrokerException, ServiceInstanceBindingExistsException, PollingException {
when(admin.getRestApi()).thenReturn(brooklynApi);
when(admin.getCredentialsFromSensors(
anyString(),
anyString(),
any(Predicate.class),
any(Predicate.class),
any(Predicate.class),
any(Predicate.class)
)).thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
when(admin.hasEffector(anyString(), anyString(), anyString())).thenReturn(new AsyncResult<>(true));
when(admin.invokeEffector(anyString(), anyString(), anyString(), anyString(), anyMap())).thenReturn(new AsyncResult<>(TASK_RESPONSE_COMPLETE));
when(brooklynApi.getActivityApi()).thenReturn(activityApi);
when(activityApi.get(anyString()))
.thenReturn(TASK_SUMMARY_INCOMPLETE)
.thenReturn(TASK_SUMMARY_INCOMPLETE)
.thenReturn(TASK_SUMMARY_INCOMPLETE)
.thenReturn(TASK_SUMMARY_INCOMPLETE)
.thenReturn(TASK_SUMMARY_COMPLETE);
doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString());
doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString(), any(Duration.class), any(Object[].class));
when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of());
when(brooklynCatalogService.getServiceDefinition(anyString())).thenReturn(serviceDefinition);
CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);
CreateServiceInstanceBindingResponse binding = bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));
// TODO assert binding was completed successfully
//assertEquals(SVC_INST_BIND_ID, binding.getServiceBindingId());
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:33,代码来源:BrooklynServiceInstanceBindingServiceTest.java
示例9: testWhitelistCreatedSuccessfully
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Test
public void testWhitelistCreatedSuccessfully() throws ServiceInstanceBindingExistsException, ServiceBrokerException {
bindingService = new BrooklynServiceInstanceBindingService(new BrooklynRestAdmin(brooklynApi, httpClient, config), bindingRepository, instanceRepository, brooklynCatalogService);
when(admin.getCredentialsFromSensors(anyString(), anyString(), any(Predicate.class), any(Predicate.class), any(Predicate.class), any(Predicate.class))).thenCallRealMethod();
when(brooklynApi.getSensorApi()).thenReturn(sensorApi);
when(sensorApi.list(anyString(), anyString())).thenReturn(ImmutableList.of(
new SensorSummary("my.sensor", "my sensor type", "my sensor description", ImmutableMap.of()),
new SensorSummary("sensor.one.name", "sensor one type", "sensor one description", ImmutableMap.of())
));
when(brooklynApi.getEntityApi()).thenReturn(entityApi);
when(entityApi.list(any())).thenReturn(ImmutableList.of(
new EntitySummary("entityId", "name", "entityType", "catalogItemId", ImmutableMap.of())
));
when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
when(brooklynCatalogService.getServiceDefinition(Mockito.anyString())).thenReturn(serviceDefinition);
when(serviceInstance.getServiceDefinitionId()).thenReturn(SVC_DEFN_ID);
when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of("planYaml", WHITELIST_YAML));
when(brooklynApi.getEffectorApi()).thenReturn(effectorApi);
when(effectorApi.invoke(anyString(), anyString(), anyString(), anyString(), anyMap())).thenReturn(bindEffectorResponse);
when(sensorApi.get(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), anyBoolean())).thenReturn("");
when(serviceInstance.getEntityId()).thenReturn("entityId");
CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);
CreateServiceInstanceBindingResponse binding = bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));
BrooklynServiceInstanceBinding expectedBinding = new BrooklynServiceInstanceBinding(SVC_INST_BIND_ID, serviceInstance.getServiceInstanceId(), EXPECTED_CREDENTIALS, "appGuid", "childEntityId");
// TODO: test binding properly
//assertEquals(expectedBinding.getAppGuid(), binding.getAppGuid());
//assertEquals(expectedBinding.getCredentials(), binding.getCredentials());
//assertEquals(expectedBinding.getServiceBindingId(), binding.getServiceBindingId());
//assertEquals(expectedBinding.getServiceInstanceId(), binding.getServiceInstanceId());
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:37,代码来源:BrooklynServiceInstanceBindingServiceTest.java
示例10: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) {
String bindingId = request.getBindingId();
String serviceInstanceId = request.getServiceInstanceId();
ServiceInstanceBinding binding = bindingRepository.findOne(bindingId);
if (binding != null) {
throw new ServiceInstanceBindingExistsException(serviceInstanceId, bindingId);
}
String database = serviceInstanceId;
String username = bindingId;
String password = RandomStringUtils.randomAlphanumeric(25);
// TODO check if user already exists in the DB
mongo.createUser(database, username, password);
Map<String, Object> credentials =
Collections.singletonMap("uri", (Object) mongo.getConnectionString(database, username, password));
binding = new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, request.getBoundAppGuid());
bindingRepository.save(binding);
return new CreateServiceInstanceAppBindingResponse().withCredentials(credentials);
}
开发者ID:spring-cloud-samples,项目名称:cloudfoundry-service-broker,代码行数:28,代码来源:MongoServiceInstanceBindingService.java
示例11: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(
CreateServiceInstanceBindingRequest request)
throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
String bindingId = request.getBindingId();
VrServiceInstanceBinding sib = repository.get(OBJECT_ID, bindingId);
if (sib != null) {
throw new ServiceInstanceBindingExistsException(request.getServiceInstanceId(), bindingId);
}
String serviceInstanceId = request.getServiceInstanceId();
VrServiceInstance si = serviceInstanceService
.getServiceInstance(serviceInstanceId);
if (si == null) {
throw new ServiceBrokerException("service instance for binding: "
+ bindingId + " is missing.");
}
// not supposed to happen per the spec, but better check...
if (si.isInProgress()) {
throw new ServiceBrokerException(
"ServiceInstance operation is still in progress.");
}
LOG.info("creating binding for service instance: "
+ request.getServiceInstanceId() + " service: "
+ request.getServiceInstanceId());
VrServiceInstanceBinding binding = new VrServiceInstanceBinding(bindingId,
serviceInstanceId, si.getCredentials(), null,
request.getBindResource());
LOG.info("saving binding: " + binding.getId());
repository.put(OBJECT_ID, binding.getId(), binding);
return new CreateServiceInstanceAppBindingResponse().withCredentials(si.getCredentials());
}
开发者ID:cf-platform-eng,项目名称:vrealize-service-broker,代码行数:43,代码来源:VrServiceInstanceBindingService.java
示例12: it_should_be_returned_with_volume_mount
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
public CreateServiceInstanceVolumeBindingStage it_should_be_returned_with_volume_mount(@CreateServiceBindingResponseJSON CreateServiceInstanceBindingResponse expected) {
Assertions.assertThat(response).isInstanceOf(CreateServiceInstanceAppBindingResponse.class);
Assertions.assertThat(response).isEqualTo(expected);
return self();
}
开发者ID:orange-cloudfoundry,项目名称:static-creds-broker,代码行数:6,代码来源:CreateServiceInstanceVolumeBindingStage.java
示例13: it_should_be_returned_with_route_service_url
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
public CreateServiceInstanceRouteBindingStage it_should_be_returned_with_route_service_url(@CreateServiceBindingResponseJSON CreateServiceInstanceBindingResponse expected) {
Assertions.assertThat(response).isInstanceOf(CreateServiceInstanceRouteBindingResponse.class);
Assertions.assertThat(response).isEqualTo(expected);
return self();
}
开发者ID:orange-cloudfoundry,项目名称:static-creds-broker,代码行数:6,代码来源:CreateServiceInstanceRouteBindingStage.java
示例14: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) {
throw nonBindableException();
}
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry-service-broker,代码行数:5,代码来源:NonBindableServiceInstanceBindingService.java
示例15: createServiceInstanceBinding
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceBindingResponse; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) {
BrooklynServiceInstanceBinding serviceInstanceBinding = getServiceInstanceBinding(request.getBindingId());
if (serviceInstanceBinding != null) {
throw new ServiceInstanceBindingExistsException(serviceInstanceBinding.getServiceInstanceId(), request.getBindingId());
}
BrooklynServiceInstance serviceInstance = instanceRepository.findOne(request.getServiceInstanceId(), false);
String entityId = serviceInstance.getEntityId();
LOG.info("creating service binding: [entity={}, serviceDefinitionId={}, bindingId={}, serviceInstanceId={}, appGuid={}",
entityId, request.getServiceDefinitionId(), request.getBindingId(), request.getServiceInstanceId(), request.getAppGuid()
);
ServiceDefinition service = catalogService.getServiceDefinition(request.getServiceDefinitionId());
Predicate<String> sensorWhitelistPredicate = x -> true;
Predicate<String> entityBlacklistPredicate = x -> true;
Predicate<String> sensorBlacklistPredicate = x -> true;
Predicate<String> entityWhitelistPredicate = x -> true;
Object planYamlObject = service.getMetadata().get("planYaml");
if (planYamlObject != null) {
Object rootElement = Iterables.getOnlyElement(Yamls.parseAll(String.valueOf(planYamlObject)));
if (rootElement instanceof Map) {
sensorWhitelistPredicate = getSensorWhitelistPredicate(rootElement);
sensorBlacklistPredicate = getSensorBlacklistPredicate(rootElement);
entityWhitelistPredicate = getEntityWhitelistPredicate(rootElement);
entityBlacklistPredicate = getEntityBlacklistPredicate(rootElement);
}
}
String childEntityId = null;
String bindResponse;
Map<String, Object> parameters = request.getParameters() != null ? request.getParameters() : ImmutableMap.of();
if (ServiceUtil.getFutureValueLoggingError(admin.hasEffector(entityId, entityId, "bind"))) {
Future<String> effector = admin.invokeEffector(entityId, entityId, "bind", "never", parameters);
bindResponse = ServiceUtil.getFutureValueLoggingError(effector);
if (bindResponse == null) {
throw new RuntimeException(String.format("cannot invoke bind effector on entity %s with %s", entityId, Iterables.toString(request.getParameters().entrySet())));
}
LOG.info("calling bind effector on entity {} with {}: {}", entityId, Iterables.toString(parameters.entrySet()), bindResponse);
JsonElement jsonElement = JsonFunctions.asJson().apply(bindResponse);
if (jsonElement instanceof JsonArray) {
childEntityId = ((JsonArray) jsonElement).get(0).getAsString();
} else {
childEntityId = jsonElement.getAsString();
}
}
Future<Map<String, Object>> credentialsFuture = admin.getCredentialsFromSensors(entityId, MoreObjects.firstNonNull(childEntityId, entityId), sensorWhitelistPredicate, sensorBlacklistPredicate, entityWhitelistPredicate, entityBlacklistPredicate);
Map<String, Object> credentials = ServiceUtil.getFutureValueLoggingError(credentialsFuture);
LOG.info("credentials: {}", Iterables.toString(credentials.entrySet()));
serviceInstanceBinding = new BrooklynServiceInstanceBinding(request.getBindingId(), request.getServiceInstanceId(), null, request.getAppGuid(), childEntityId);
bindingRepository.save(serviceInstanceBinding);
return new CreateServiceInstanceAppBindingResponse().withCredentials(credentials);
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:56,代码来源:BrooklynServiceInstanceBindingService.java