org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest Java Examples

The following examples show how to use org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest. 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: ExampleServiceInstanceService.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request) {
	String serviceInstanceId = request.getServiceInstanceId();
	String planId = request.getPlanId();
	String previousPlan = request.getPreviousValues().getPlanId();
	Map<String, Object> parameters = request.getParameters();

	//
	// perform the steps necessary to initiate the asynchronous
	// updating of all necessary resources
	//

	return Mono.just(UpdateServiceInstanceResponse.builder()
			.async(true)
			.build());
}
 
Example #2
Source File: AppDeploymentUpdateServiceInstanceWorkflowTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
private UpdateServiceInstanceRequest buildRequest(String serviceName, String planName,
	Map<String, Object> parameters) {
	return UpdateServiceInstanceRequest
		.builder()
		.serviceInstanceId("service-instance-id")
		.serviceDefinitionId(serviceName + "-id")
		.planId(planName + "-id")
		.serviceDefinition(ServiceDefinition.builder()
			.id(serviceName + "-id")
			.name(serviceName)
			.plans(Plan.builder()
				.id(planName + "-id")
				.name(planName)
				.build())
			.build())
		.plan(Plan.builder()
			.id(planName + "-id")
			.name(planName)
			.build())
		.parameters(parameters == null ? new HashMap<>() : parameters)
		.build();
}
 
Example #3
Source File: AppDeploymentUpdateServiceInstanceWorkflowTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
private void setupMocks(UpdateServiceInstanceRequest request) {
	given(this.appDeploymentService.update(eq(backingApps), eq(request.getServiceInstanceId())))
		.willReturn(Flux.just("app1", "app2"));

	given(
		this.appsParametersTransformationService.transformParameters(eq(backingApps), eq(request.getParameters())))
		.willReturn(Mono.just(backingApps));
	given(this.servicesParametersTransformationService
		.transformParameters(eq(backingServices), eq(request.getParameters())))
		.willReturn(Mono.just(backingServices));

	given(this.targetService.addToBackingApplications(eq(backingApps), eq(targetSpec), eq("service-instance-id")))
		.willReturn(Mono.just(backingApps));
	given(this.targetService
		.addToBackingServices(eq(backingServices), eq(targetSpec), eq(request.getServiceInstanceId())))
		.willReturn(Mono.just(backingServices));
}
 
Example #4
Source File: AppDeploymentUpdateServiceInstanceWorkflowTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceWithParametersSucceeds() {
	UpdateServiceInstanceRequest request = buildRequest("service1", "plan1",
		singletonMap("ENV_VAR_1", "value from parameters"));
	UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().build();

	setupMocks(request);
	mockNoChangeInBackingServices(request);

	StepVerifier
		.create(updateServiceInstanceWorkflow.update(request, response))
		.expectNext()
		.expectNext()
		.verifyComplete();

	verifyNoMoreInteractionsWithServices();
}
 
Example #5
Source File: AppDeploymentUpdateServiceInstanceWorkflowTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings({"UnassignedFluxMonoInstance"})
void updateServiceInstanceSucceeds() {
	UpdateServiceInstanceRequest request = buildRequest("service1", "plan1");
	UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().build();

	setupMocks(request);
	mockNoChangeInBackingServices(request);

	StepVerifier
		.create(updateServiceInstanceWorkflow.update(request, response))
		.expectNext()
		.expectNext()
		.verifyComplete();

	verify(appDeploymentService).update(backingApps, request.getServiceInstanceId());
	verify(servicesProvisionService).updateServiceInstance(backingServices);

	final String expectedServiceId = "service-instance-id";
	verify(targetService).addToBackingServices(backingServices, targetSpec, expectedServiceId);
	verify(targetService).addToBackingApplications(backingApps, targetSpec, expectedServiceId);

	verifyNoMoreInteractionsWithServices();
}
 
Example #6
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceWithoutSyncAndHeadersSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(UpdateServiceInstanceResponse.builder()
			.build());

	MvcResult mvcResult = mockMvc.perform(patch(buildCreateUpdateUrl())
			.content(updateRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isOk())
			.andExpect(content().string("{}"));

	UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertThat(actualRequest.getServiceDefinition().getPlans().size()).isEqualTo(3);
	assertThat(actualRequest.getPlan()).isNull();
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #7
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceFiltersPlansSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(UpdateServiceInstanceResponse
			.builder()
			.build());

	MvcResult mvcResult = mockMvc
			.perform(patch(buildCreateUpdateUrl())
					.content(updateRequestBodyWithPlan)
					.contentType(MediaType.APPLICATION_JSON)
					.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isOk())
			.andExpect(content().string("{}"));

	UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId());
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #8
Source File: ServiceInstanceControllerRequestTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceParametersAreMappedToRequest() {
	UpdateServiceInstanceRequest parsedRequest = buildUpdateRequest().build();

	UpdateServiceInstanceRequest expectedRequest = buildUpdateRequest()
			.asyncAccepted(true)
			.serviceInstanceId("service-instance-id")
			.platformInstanceId("platform-instance-id")
			.apiInfoLocation("api-info-location")
			.originatingIdentity(identityContext)
			.requestIdentity("request-id")
			.serviceDefinition(serviceDefinition)
			.plan(plan)
			.build();

	ServiceInstanceController controller = createControllerUnderTest(expectedRequest);

	controller.updateServiceInstance(pathVariables, "service-instance-id", true,
			"api-info-location", encodeOriginatingIdentity(identityContext), "request-id",
			parsedRequest)
			.block();
}
 
Example #9
Source File: TestServiceInstanceService.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request) {
	if (IN_PROGRESS_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) {
		return Mono.error(new ServiceBrokerUpdateOperationInProgressException("task_10"));
	}
	if (UNKNOWN_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) {
		return Mono.error(new ServiceInstanceDoesNotExistException(UNKNOWN_SERVICE_INSTANCE_ID));
	}
	if (request.isAsyncAccepted()) {
		return Mono.just(UpdateServiceInstanceResponse.builder()
				.async(true)
				.operation("working")
				.dashboardUrl("https://dashboard.example.local")
				.build());
	}
	else {
		return Mono.just(UpdateServiceInstanceResponse.builder()
				.dashboardUrl("https://dashboard.example.local")
				.build());
	}
}
 
Example #10
Source File: ServiceInstanceControllerResponseCodeTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
private void validateUpdateServiceInstanceWithResponseStatus(UpdateServiceInstanceResponse response,
		HttpStatus expectedStatus) {
	Mono<UpdateServiceInstanceResponse> responseMono;
	if (response == null) {
		responseMono = Mono.empty();
	}
	else {
		responseMono = Mono.just(response);
	}
	given(serviceInstanceService.updateServiceInstance(any(UpdateServiceInstanceRequest.class)))
			.willReturn(responseMono);

	UpdateServiceInstanceRequest updateRequest = UpdateServiceInstanceRequest.builder()
			.serviceDefinitionId("service-definition-id")
			.build();

	ResponseEntity<UpdateServiceInstanceResponse> responseEntity = controller
			.updateServiceInstance(pathVariables, null, false, null, null, null,
					updateRequest)
			.block();

	assertThat(responseEntity).isNotNull();
	assertThat(responseEntity.getStatusCode()).isEqualTo(expectedStatus);
	assertThat(responseEntity.getBody()).isEqualTo(response);
}
 
Example #11
Source File: ServiceInstanceEventServiceTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceSucceeds() {
	prepareUpdateEventFlows();

	StepVerifier
			.create(serviceInstanceEventService.updateServiceInstance(
					UpdateServiceInstanceRequest.builder()
							.serviceInstanceId("service-instance-id")
							.serviceDefinitionId("service-def-id")
							.build()))
			.expectNext(UpdateServiceInstanceResponse.builder().build())
			.verifyComplete();

	assertThat(this.results.getBeforeUpdate()).isEqualTo("before service-instance-id");
	assertThat(this.results.getAfterUpdate()).isEqualTo("after service-instance-id");
	assertThat(this.results.getErrorUpdate()).isNullOrEmpty();
}
 
Example #12
Source File: ServiceInstanceEventServiceTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceFails() {
	prepareUpdateEventFlows();

	StepVerifier
			.create(serviceInstanceEventService.updateServiceInstance(
					UpdateServiceInstanceRequest.builder()
							.serviceInstanceId("service-instance-id")
							.build()))
			.expectError()
			.verify();

	assertThat(this.results.getBeforeUpdate()).isEqualTo("before service-instance-id");
	assertThat(this.results.getAfterUpdate()).isNullOrEmpty();
	assertThat(this.results.getErrorUpdate()).isEqualTo("error service-instance-id");
}
 
Example #13
Source File: WorkflowServiceInstanceService.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
private Mono<Void> update(UpdateServiceInstanceRequest request, UpdateServiceInstanceResponse response) {
	return stateRepository.saveState(request.getServiceInstanceId(),
		OperationState.IN_PROGRESS, "update service instance started")
		.thenMany(invokeUpdateWorkflows(request, response)
			.doOnRequest(l -> {
				LOG.info("Updating service instance");
				LOG.debug("request={}", request);
			})
			.doOnComplete(() -> {
				LOG.info("Finish updating service instance");
				LOG.debug("request={}, response={}", request, response);
			})
			.doOnError(e -> LOG.error(String.format("Error updating service instance. error=%s",
				e.getMessage()), e)))
		.thenEmpty(stateRepository.saveState(request.getServiceInstanceId(),
			OperationState.SUCCEEDED, "update service instance completed")
			.then())
		.onErrorResume(exception -> stateRepository.saveState(request.getServiceInstanceId(),
			OperationState.FAILED, exception.getMessage())
			.then());
}
 
Example #14
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceWithoutAsyncAndHeadersSucceeds() {
	setupCatalogService();

	setupServiceInstanceService(UpdateServiceInstanceResponse.builder()
			.build());

	client.patch().uri(buildCreateUpdateUrl())
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(updateRequestBody)
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isOk()
			.expectBody()
			.json("{}");

	UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertThat(actualRequest.getPlan()).isNull();
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #15
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceFiltersPlansSucceeds() {
	setupCatalogService();

	setupServiceInstanceService(UpdateServiceInstanceResponse.builder()
			.build());

	client.patch().uri(buildCreateUpdateUrl())
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(updateRequestBodyWithPlan)
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isOk()
			.expectBody()
			.json("{}");

	UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertThat(actualRequest.getPlan().getId()).isEqualTo("plan-three-id");
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #16
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void updateServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(UpdateServiceInstanceResponse.builder()
			.async(true)
			.operation("working")
			.dashboardUrl("https://dashboard.app.local")
			.build());

	client.patch().uri(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true))
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(updateRequestBody)
			.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
			.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isAccepted()
			.expectBody()
			.jsonPath("$.operation").isEqualTo("working")
			.jsonPath("$.dashboard_url").isEqualTo("https://dashboard.app.local");

	UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example #17
Source File: AbstractServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@BeforeEach
public void setUpCommonFixtures() {
	this.createRequestBody = JsonUtils.toJson(CreateServiceInstanceRequest.builder()
			.serviceDefinitionId(serviceDefinition.getId())
			.planId("plan-one-id")
			.build());

	this.updateRequestBody = JsonUtils.toJson(UpdateServiceInstanceRequest.builder()
			.serviceDefinitionId(serviceDefinition.getId())
			.build());

	this.updateRequestBodyWithPlan = JsonUtils.toJson(UpdateServiceInstanceRequest.builder()
			.serviceDefinitionId(serviceDefinition.getId())
			.planId("plan-three-id")
			.build());
}
 
Example #18
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void updateServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(UpdateServiceInstanceResponse.builder()
			.async(true)
			.operation("working")
			.dashboardUrl("https://dashboard.app.local")
			.build());

	MvcResult mvcResult = mockMvc.perform(patch(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true))
			.content(updateRequestBody)
			.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
			.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isAccepted())
			.andExpect(jsonPath("$.operation", equalTo("working")))
			.andExpect(jsonPath("$.dashboard_url", equalTo("https://dashboard.app.local")));

	UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example #19
Source File: ServiceInstanceControllerRequestTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void updateServiceInstanceWithInvalidServiceDefinitionIdThrowsException() {
	UpdateServiceInstanceRequest updateRequest = UpdateServiceInstanceRequest.builder()
			.serviceDefinitionId("unknown-service-definition-id")
			.build();

	ServiceInstanceController controller = createControllerUnderTest();

	assertThrows(ServiceDefinitionDoesNotExistException.class, () ->
			controller.updateServiceInstance(pathVariables, null, false,
					null, null, null, updateRequest)
					.block());
}
 
Example #20
Source File: WorkflowServiceInstanceService.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Mono<UpdateServiceInstanceResponse> invokeUpdateResponseBuilders(UpdateServiceInstanceRequest request) {
	AtomicReference<UpdateServiceInstanceResponseBuilder> responseBuilder =
		new AtomicReference<>(UpdateServiceInstanceResponse.builder());

	return Flux.fromIterable(updateServiceInstanceWorkflows)
		.filterWhen(workflow -> workflow.accept(request))
		.flatMap(workflow -> workflow.buildResponse(request, responseBuilder.get())
			.doOnNext(responseBuilder::set))
		.last(responseBuilder.get())
		.map(UpdateServiceInstanceResponseBuilder::build);
}
 
Example #21
Source File: AppDeploymentUpdateServiceInstanceWorkflow.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Mono<Map<String, BackingService>> getExistingBackingServiceNameMap(UpdateServiceInstanceRequest request) {
	return backingAppManagementService.getDeployedBackingApplications(request.getServiceInstanceId(),
		request.getServiceDefinition().getName(), request.getPlan().getName())
		.flatMapMany(Flux::fromIterable)
		.map(BackingApplication::getServices)
		.flatMap(Flux::fromIterable)
		.distinct()
		.map(servicesSpec -> BackingService.builder()
			.serviceInstanceName(servicesSpec.getServiceInstanceName())
			.build())
		.collectMap(BackingService::getServiceInstanceName, Function.identity());
}
 
Example #22
Source File: AppDeploymentUpdateServiceInstanceWorkflow.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Flux<String> updateBackingApplications(UpdateServiceInstanceRequest request) {
	return getBackingApplicationsForService(request.getServiceDefinition(), request.getPlan())
		.flatMap(backingApps -> getTargetForService(request.getServiceDefinition(), request.getPlan())
			.flatMap(targetSpec -> targetService.addToBackingApplications(backingApps, targetSpec,
				request.getServiceInstanceId()))
			.defaultIfEmpty(backingApps))
		.flatMap(backingApps ->
			appsParametersTransformationService.transformParameters(backingApps, request.getParameters()))
		.flatMapMany(backingApps -> deploymentService.update(backingApps, request.getServiceInstanceId()))
		.doOnRequest(l -> {
			LOG.info("Updating backing applications. serviceDefinitionName={}, planName={}",
				request.getServiceDefinition().getName(), request.getPlan().getName());
			LOG.debug(REQUEST_LOG_TEMPLATE, request);
		})
		.doOnComplete(() -> {
			LOG.info("Finish updating backing applications. serviceDefinitionName={}, planName={}",
				request.getServiceDefinition().getName(), request.getPlan().getName());
			LOG.debug(REQUEST_LOG_TEMPLATE, request);
		})
		.doOnError(e -> {
			if (LOG.isErrorEnabled()) {
				LOG.error(String.format("Error updating backing applications. serviceDefinitionName=%s, " +
						"planName=%s, error=%s", request.getServiceDefinition().getName(), request.getPlan().getName(),
					e.getMessage()), e);
			}
			LOG.debug(REQUEST_LOG_TEMPLATE, request);
		});
}
 
Example #23
Source File: ExampleServiceInstanceEventFlowsConfiguration2.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public UpdateServiceInstanceErrorFlow updateServiceInstanceErrorFlow() {
	return new UpdateServiceInstanceErrorFlow() {
		@Override
		public Mono<Void> error(UpdateServiceInstanceRequest request, Throwable t) {
			//
			// do something if an error occurs while updating an instance
			//
			return Mono.empty();
		}
	};
}
 
Example #24
Source File: ServiceInstanceController.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
/**
 * REST controller for updating a service instance
 *
 * @param pathVariables the path variables
 * @param serviceInstanceId the service instance ID
 * @param acceptsIncomplete indicates an asynchronous request
 * @param apiInfoLocation location of the API info endpoint of the platform instance
 * @param originatingIdentityString identity of the user that initiated the request from the platform
 * @param requestIdentity identity of the request sent from the platform
 * @param request the request body
 * @return the response
 */
@PatchMapping({PLATFORM_PATH_MAPPING, PATH_MAPPING})
public Mono<ResponseEntity<UpdateServiceInstanceResponse>> updateServiceInstance(
		@PathVariable Map<String, String> pathVariables,
		@PathVariable(ServiceBrokerRequest.INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId,
		@RequestParam(value = AsyncServiceBrokerRequest.ASYNC_REQUEST_PARAMETER, required = false) boolean acceptsIncomplete,
		@RequestHeader(value = ServiceBrokerRequest.API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation,
		@RequestHeader(value = ServiceBrokerRequest.ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString,
		@RequestHeader(value = ServiceBrokerRequest.REQUEST_IDENTITY_HEADER, required = false) String requestIdentity,
		@Valid @RequestBody UpdateServiceInstanceRequest request) {
	return getRequiredServiceDefinition(request.getServiceDefinitionId())
			.flatMap(serviceDefinition -> getServiceDefinitionPlan(serviceDefinition, request.getPlanId())
					.map(plan -> {
						request.setPlan(plan);
						return request;
					})
					.switchIfEmpty(Mono.just(request))
					.map(req -> {
						req.setServiceInstanceId(serviceInstanceId);
						req.setServiceDefinition(serviceDefinition);
						return req;
					}))
			.flatMap(req -> configureCommonRequestFields(req,
					pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation,
					originatingIdentityString, requestIdentity, acceptsIncomplete))
			.cast(UpdateServiceInstanceRequest.class)
			.flatMap(req -> service.updateServiceInstance(req)
					.doOnRequest(v -> {
						LOG.info("Updating service instance");
						LOG.debug(DEBUG_REQUEST, request);
					})
					.doOnSuccess(response -> {
						LOG.info("Updating service instance succeeded");
						LOG.debug(DEBUG_RESPONSE, serviceInstanceId, response);
					})
					.doOnError(e -> LOG.error("Error updating service instance. error=" + e.getMessage(), e)))
			.map(response -> new ResponseEntity<>(response, getAsyncResponseCode(response)))
			.switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK)));
}
 
Example #25
Source File: ServiceInstanceEventService.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request) {
	return flows.getUpdateInstanceRegistry().getInitializationFlows(request)
			.then(service.updateServiceInstance(request))
			.onErrorResume(e -> flows.getUpdateInstanceRegistry().getErrorFlows(request, e)
					.then(Mono.error(e)))
			.flatMap(response -> flows.getUpdateInstanceRegistry().getCompletionFlows(request, response)
					.then(Mono.just(response)));
}
 
Example #26
Source File: Fixtures.java    From ecs-cf-service-broker with Apache License 2.0 5 votes vote down vote up
public static UpdateServiceInstanceRequest namespaceUpdateRequestFixture(
        Map<String, Object> params) {
    return UpdateServiceInstanceRequest.builder()
            .serviceDefinitionId(NAMESPACE_SERVICE_ID)
            .planId(NAMESPACE_PLAN_ID1)
            .parameters(params)
            .serviceInstanceId(NAMESPACE)
            .build();
}
 
Example #27
Source File: Fixtures.java    From ecs-cf-service-broker with Apache License 2.0 5 votes vote down vote up
public static UpdateServiceInstanceRequest bucketUpdateRequestFixture(
        Map<String, Object> params) {
    return UpdateServiceInstanceRequest.builder()
            .serviceDefinitionId(BUCKET_SERVICE_ID)
            .planId(BUCKET_PLAN_ID1)
            .parameters(params)
            .serviceInstanceId(BUCKET_NAME)
            .build();
}
 
Example #28
Source File: EventFlowsAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public UpdateServiceInstanceInitializationFlow updateInitFlow() {
	return new UpdateServiceInstanceInitializationFlow() {
		@Override
		public Mono<Void> initialize(UpdateServiceInstanceRequest request) {
			return Mono.empty();
		}
	};
}
 
Example #29
Source File: EventFlowsAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public UpdateServiceInstanceCompletionFlow updateCompleteFlow() {
	return new UpdateServiceInstanceCompletionFlow() {
		@Override
		public Mono<Void> complete(UpdateServiceInstanceRequest request,
				UpdateServiceInstanceResponse response) {
			return Mono.empty();
		}
	};
}
 
Example #30
Source File: EventFlowsAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public UpdateServiceInstanceErrorFlow updateErrorFlow() {
	return new UpdateServiceInstanceErrorFlow() {
		@Override
		public Mono<Void> error(UpdateServiceInstanceRequest request, Throwable t) {
			return Mono.empty();
		}
	};
}