use of org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceController method deleteServiceInstance.
@DeleteMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}", "/v2/service_instances/{instanceId}" })
public ResponseEntity<DeleteServiceInstanceResponse> deleteServiceInstance(@PathVariable Map<String, String> pathVariables, @PathVariable(INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @RequestParam(SERVICE_ID_PARAMETER) String serviceDefinitionId, @RequestParam(PLAN_ID_PARAMETER) String planId, @RequestParam(value = ASYNC_REQUEST_PARAMETER, required = false) boolean acceptsIncomplete, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString) {
ServiceDefinition serviceDefinition = getRequiredServiceDefinition(serviceDefinitionId);
DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder().serviceInstanceId(serviceInstanceId).serviceDefinitionId(serviceDefinitionId).planId(planId).serviceDefinition(serviceDefinition).asyncAccepted(acceptsIncomplete).platformInstanceId(pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE)).apiInfoLocation(apiInfoLocation).originatingIdentity(parseOriginatingIdentity(originatingIdentityString)).build();
LOGGER.debug("Deleting a service instance: request={}", request);
try {
DeleteServiceInstanceResponse response = service.deleteServiceInstance(request);
LOGGER.debug("Deleting a service instance succeeded: serviceInstanceId={}, response={}", serviceInstanceId, response);
return new ResponseEntity<>(response, getAsyncResponseCode(response));
} catch (ServiceInstanceDoesNotExistException e) {
LOGGER.debug("Service instance does not exist: ", e);
return new ResponseEntity<>(DeleteServiceInstanceResponse.builder().build(), HttpStatus.GONE);
}
}
use of org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition in project spring-cloud-open-service-broker by spring-cloud.
the class ExampleCatalogConfiguration method catalog.
@Bean
public Catalog catalog() {
Plan plan = Plan.builder().id("simple-plan").name("standard").description("A simple plan").free(true).build();
ServiceDefinition serviceDefinition = ServiceDefinition.builder().id("example-service").name("example").description("A simple example").bindable(true).tags("example", "tags").plans(plan).build();
return Catalog.builder().serviceDefinitions(serviceDefinition).build();
}
use of org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceController method updateServiceInstance.
@PatchMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}", "/v2/service_instances/{instanceId}" })
public ResponseEntity<UpdateServiceInstanceResponse> updateServiceInstance(@PathVariable Map<String, String> pathVariables, @PathVariable(INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @RequestParam(value = ASYNC_REQUEST_PARAMETER, required = false) boolean acceptsIncomplete, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString, @Valid @RequestBody UpdateServiceInstanceRequest request) {
ServiceDefinition serviceDefinition = getRequiredServiceDefinition(request.getServiceDefinitionId());
request.setServiceInstanceId(serviceInstanceId);
request.setServiceDefinition(serviceDefinition);
setCommonRequestFields(request, pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation, originatingIdentityString, acceptsIncomplete);
LOGGER.debug("Updating a service instance: request={}", request);
UpdateServiceInstanceResponse response = service.updateServiceInstance(request);
LOGGER.debug("Updating a service instance succeeded: serviceInstanceId={}, response={}", serviceInstanceId, response);
return new ResponseEntity<>(response, getAsyncResponseCode(response));
}
use of org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceController method createServiceInstance.
@PutMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}", "/v2/service_instances/{instanceId}" })
public ResponseEntity<CreateServiceInstanceResponse> createServiceInstance(@PathVariable Map<String, String> pathVariables, @PathVariable(INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @RequestParam(value = ASYNC_REQUEST_PARAMETER, required = false) boolean acceptsIncomplete, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString, @Valid @RequestBody CreateServiceInstanceRequest request) {
ServiceDefinition serviceDefinition = getRequiredServiceDefinition(request.getServiceDefinitionId());
request.setServiceInstanceId(serviceInstanceId);
request.setServiceDefinition(serviceDefinition);
setCommonRequestFields(request, pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation, originatingIdentityString, acceptsIncomplete);
LOGGER.debug("Creating a service instance: request={}", request);
CreateServiceInstanceResponse response = service.createServiceInstance(request);
LOGGER.debug("Creating a service instance succeeded: serviceInstanceId={}, response={}", serviceInstanceId, response);
return new ResponseEntity<>(response, getCreateResponseCode(response));
}
use of org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerResponseCodeTest method setUp.
@BeforeEach
void setUp() {
controller = new ServiceInstanceBindingController(catalogService, bindingService);
ServiceDefinition serviceDefinition = mock(ServiceDefinition.class);
List<Plan> plans = new ArrayList<>();
plans.add(Plan.builder().id("service-definition-plan-id").build());
given(serviceDefinition.getPlans()).willReturn(plans);
given(serviceDefinition.getId()).willReturn("service-definition-id");
given(catalogService.getServiceDefinition(any())).willReturn(Mono.just(serviceDefinition));
}
Aggregations