Skip to content

Return 410 GONE on GET /v2/service_instances/:instance_id/service_bindings/:binding_id/last_operation #458

@flo-hauser

Description

@flo-hauser

Hey,
I think it would be good to be able to return a 410 GONE Status on GET /v2/service_instances/:instance_id/service_bindings/:binding_id/last_operation if the binding is removed upon a asynchronous delete binding request.

I think that would be more spec compliant, according to polling-last-operation-for-service-bindings

idea for solution
As in instance last operation, wrap the result = service_broker.last_binding_operation(...) call in try..catch like so:

    @openbroker.route(
        "/v2/service_instances/<instance_id>/service_bindings/<binding_id>/last_operation",
        methods=["GET"],
    )
    def last_binding_operation(instance_id, binding_id):
        service_id = request.args.get("service_id", None)
        plan_id = request.args.get("plan_id", None)

        operation_data = request.args.get("operation", None)

        try: 
            result = service_broker.last_binding_operation(
                instance_id=instance_id,
                binding_id=binding_id,
                operation_data=operation_data,
                service_id=service_id,
                plan_id=plan_id,
            )
            if result is None:
                warnings.warn("Last Binding Operation has to return a LastOperation", stacklevel=0)
                raise errors.ServiceException("Internal broker error")
            return (
                to_json_response(LastOperationResponse(result.state, result.description)),
                HTTPStatus.OK,
            )
        except errors.ErrBindingDoesNotExist:
            return (
                to_json_response(LastOperationResponse(OperationState.SUCCEEDED, "")),
                HTTPStatus.GONE,
            )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions