spring-cloud / spring-cloud-open-service-broker

Spring Cloud project for creating service brokers that conform to the Open Server Broker API specification
https://spring.io/projects/spring-cloud-open-service-broker
Apache License 2.0
168 stars 118 forks source link

Not able to throw 400 BAD Request #288

Closed chourasiya closed 4 years ago

chourasiya commented 4 years ago

Hello team, I am implementing the service broker using Spring.

I have provided an implementation class for CreateServiceInstanceService. In this, according to the OSBAPI specification given here If someone provides already existing instanceId but with different attributes, we should throw 400 status. But I am unable to find a way to achieve this. Will you please help me out.

Can Anyone help me which class i have to use to throw 400 BAD Request.

Thanks.

royclarkson commented 4 years ago

Are you referring to the provisioning response codes seen here? https://github.com/openservicebrokerapi/servicebroker/blob/v2.15/spec.md#response-3

In the case you described, I believe the following is the correct response:

409 Conflict - MUST be returned if a Service Instance with the same id already exists or is being provisioned but with different attributes.

To return a 409, you may throw a ServiceInstanceExistsException.

This should answer the question, so I'm closing the issue. But feel free to reopen if you need more information.

chourasiya commented 4 years ago

@royclarkson As you can see in below url there are 400 response status as well : https://github.com/openservicebrokerapi/servicebroker/blob/v2.15/spec.md#response-3

I just wanted to know which class i have to use to throw 400 status code.

royclarkson commented 4 years ago

Thanks for clarifying. You can use the ServiceBrokerInvalidParametersException to return a 400 response. Generally, you can review the ServiceBrokerExceptionHandler or its subclasses to see what response is returned for which exception.

chourasiya commented 4 years ago

@royclarkson Hi can you tell me witch class i have to use to throw 410 status code in case of unbind service broker endpoint.

Find more details in below url : https://github.com/openservicebrokerapi/servicebroker/blob/v2.15/spec.md#unbinding

royclarkson commented 4 years ago

@chourasiya please see ServiceInstanceBindingDoesNotExistException